Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
This is a WSGI middleware that answers CORS preflight requests and adds the needed header to the response. For CORS see: http://www.w3.org/TR/cors/
Either plug it in programmatically as in this pyramid example:
.. code:: python
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
def get_root(request):
return {}
config = Configurator(root_factory=get_root, settings=settings)
config.begin()
# whatever it takes to config your app goes here
config.end()
from wsgicors import CORS
return CORS(config.make_wsgi_app(), headers="*", methods="*", maxage="180", origin="*")
or plug it into your wsgi pipeline via paste ini to let it serve by waitress for instance:
::
[app:myapp]
use = egg:mysuperapp#app
###
# wsgi server configuration
###
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
[pipeline:main]
pipeline =
cors
myapp
[filter:cors]
use = egg:wsgicors#middleware
# define a "free" policy
free_origin=copy
free_headers=*
free_expose_headers=*
free_methods=HEAD, OPTIONS, GET
free_maxage=180
# define a "subdom" policy
subdom_origin=http://example.com http://example2.com https://*.example.com
subdom_headers=*
subdom_methods=HEAD, OPTIONS, GET, POST, PUT, DELETE
subdom_expose_headers=Foo, Doom
subdom_maxage=180
# define a combination of policies, they are evaluated in the order given by the policy keyword
# the first that matches the request's origin will be used
policy=subdom,free
# policy matching strategy
# matchstrategy=firstmatch
Keywords are:
origin
headers
methods
credentials
maxage
for origin
:
copy
which will copy whatever origin the request comes from*
or ?
(fnmatch lib is used for matching). If a match is
found the original host is returned.*
for instance
to allow any source)for headers
:
*
which will allow whatever header is asked forfor expose_headers
:
*
to allow access to any header the client might wish to accessfor methods
:
*
which will allow whatever method is asked forPOST, PATCH, PUT, DELETE
for instance)for credentials
:
true
Access-Control-Allow-Credentials
is sent)for maxage
:
As can be seen in the example above, a policy needs to be created with
the policy
keyword. The options need then be prefixed with the
policy name and a _
.
The policy
keyword itself can be a comma separated list. If so the origin of the request is matched against the origins defined in the policies and the first matching is the policy used.
An alternative matching strategy would be verbmatch
, that selects the first of the listed that also matches the request method. To switch between the strategies use the
matchstrategy
keyword:
firstmatch
(the default) to select the first of the policies that matches on the origin
keywordverbmatch
to select the first of the policies that matches on the methods
and origin
keywordverbmulti
matching strategy, that matches the first listed policy that also matches the requested METHODVary
is set to Origin
if origin policy differs from *
origin
now takes space separated list of hostnames. They can be
filename patterns like *.domain.tld“wsgicors” is written and maintained by Norman Krämer.
The following people contributed directly or indirectly to this project:
Julien De Vos <https://github.com/JDeVos>
_Ryan Shaw <https://github.com/ryankshaw>
_David Douard <https://github.com/douardda>
_MattSANU <https://github.com/MattSANU>
_Sami Salonen <https://github.com/ssalonen>
_Sami Salonen <https://github.com/ssalonen>
_Wouter Claeys <https://github.com/claeyswo>
_
Please add yourself here when you submit your first pull request.FAQs
WSGI for Cross Origin Resource Sharing (CORS)
We found that wsgicors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.