web_security | the learning notes of web security | Learning library
kandi X-RAY | web_security Summary
kandi X-RAY | web_security Summary
the learning notes of web security
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of web_security
web_security Key Features
web_security Examples and Code Snippets
Community Discussions
Trending Discussions on web_security
QUESTION
I'm hosting a static website on AWS (stored in S3, with CloudFront + Lambda@Edge). I've added some basic javascript to respond to button clicks (since I will be sending the form data to AWS API Gateway using AJAX, etc), but the javascript only seems to work locally, not online.
To be specific, if you go to my website and click on the button, nothing happens, regardless of what you enter in the text field. But if you "View page source" and save it locally, it will respond as expected (alerts pop-up and text field changes color depending on whether or not id is valid).
I've used jslint and regex101 to check and clean my code. I've removed all CSS and unrelated content. I've also reproduced the problem on several devices and browsers (always works fine locally). I'm pretty new to AWS and Javascript, so maybe it's something basic, but I've hit a roadblock after several days. Any help would be much appreciated!
I'm reproducing the html below (for posterity):
...ANSWER
Answered 2021-Mar-25 at 05:54Well, a few key lessons I learned here:
- Best way to debug (non-responsive) JavaScript is browser's More tools > Developer Tools > Console tab. Without this, I was flying blind.
- The problem was not with the JavaScript, but rather with the security headers I was adding. I had followed this AWS article without a deep understanding of the directives, and they blocked my JavaScript.
- Inline JavaScript is bad! Make sure you put all your scripts into a separate file. Maybe this is obvious to you, but I had to read this article to understand why. Plus I have seen many Stack Overflow questions with inline JavaScript, so I question if this is really well known...
- Use the Mozilla Observatory and Google's CSP Evaluator to check and improve your website's security.
In the end, I used the following Content-Security-Policy headers:
QUESTION
I've built a web application (with my favourite language Fantom!) and am in the process of locking it down from XSS and other such attacks by supplying industry standard HTTP response headers.
My question is, for which responses should the headers be set?
I could set the headers for every response, but that seems pretty wasteful given most requests will be for images, fonts, stylesheets, etc.. The Content-Security-Policy
in particular can get quite lengthy.
As a lot of the headers relate to the owning HTML page (and the Javascript contained within), I get the feeling most of them need only be set for HTML pages.
I've looked at various resources such as:
And while they explain what the headers do, they don't explain for which resources they should be used and served for!
I've made a list below of HTTP response headers and for which Content-Types
I think they should be served with. But does anyone know if this is correct?
ANSWER
Answered 2018-Jan-09 at 17:16Theoretically, only 'active' documents should need it much like the X-XSS-Protection header (related answer here from Info Security). As long as the policy is set on the main document (even through a Meta tag), external resources should be blocked based on that policy, not the policy on the external resource (easy to see when loading CDN files which almost certainly do not have your CSP, or any CSP, set).
So I would say your estimate is correct; text/HTML and XML absolutely should have it, anything that can execute Javascript. It shouldn't matter for static resources. They'll be blocked or allowed based on the main Document's CSP.
I will admit that personally I simply send them on all resources served directly from my server as I'd rather be paranoid than screw something up and the few dozen bytes per request don't appear to be a big impact especially on a site that doesn't serve a great deal of requests. And if your site does serve an extreme amount of requests...usually best to cut down on requests before trying to shrink your headers.
As with anything like this I'd be sure to test your specific implementation and try loading some resources the CSP should block. You never know when a browser implementation may be flawed (or more frequently, a typo or over/under eager application of your own rules).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install web_security
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page