awakesecurity / csp Goto Github PK
View Code? Open in Web Editor NEWContent Security Policy HTTP middleware
License: Other
Content Security Policy HTTP middleware
License: Other
We ran into an interesting corner case at Awake Security and while we have an immediate internal work-around we wanted to discuss here what is the more idiomatic solution
The specific problem we ran into was the following scenario:
nghttpx
proxy that is terminating TLS, meaning:
localhost:somePort
to the serverwss://localhost:somePort
They reason why is that the content-security middleware from this library is based on whether or not the request is using TLS. If the request doesn't use TLS then the connect-src
field of the content-security policy is set to:
connect-src 'self' ws://localhost:somePort
... and if the request does use TLS then the content-security policy is set to:
connect-src 'self' wss://localhost:somePort
The relevant code is here:
Lines 130 to 134 in 7896a03
When users create an SSH tunnel to localhost
the 'self'
whitelist doesn't apply and if the server receives a request that does not use TLS (because the proxy terminates TLS) then the content-security policy rejects secure websocket connections
The immediate workaround we have is to disable the conditional switch and always add both ws://localhost:somePort
and wss://localhost:somePort
to the content-security policy for all requests. However, that seems like overkill and we weren't sure if we should open up a pull request to do that. Is there a more robust way to support this use case?
Another possibility is to not handle this in the middleware layer at all and instead handle this in the proxy. In other words, since the proxy TLS terminates TLS then perhaps it should also rewrite the content-security policy to replace whitelisted insecure protocols with their secure counterparts
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.