News for hackers. Stuff that matters.
Re:How widely used are security-based HTTP response headers? by STRML on Sunday August 30, 2015 @10:32AM (#10143415)
It's unfortunate that response headers on a secure website need to be bloated so much to receive benefits that should be default on modern sites. I imagine a world where you specifically have to opt-in to unsafe behavior, not the other way around, but of course this would break many existing sites.

For those of you looking at this, I've found the X-Frame-Options (to prevent clickjacking via iframe) and Content-Security-Policy (to restrict eval, inline JS, JS and embed sources and more) to be the most useful headers by far. If you can run CSP without 'unsafe-eval' or 'unsafe-inline' and restrict all sources to your local domain, your site's security will be much better for it as an entire range of attacks is eliminated on modern browsers.

Of course they are all worth looking at. Scott's header test (https://securityheaders.io) is a great check for your own sites.

Re:How widely used are security-based HTTP response headers? by JoshTriplett on Sunday August 30, 2015 @12:56PM (#10143806)
> I've found the X-Frame-Options (to prevent clickjacking via iframe)

I wish some way existed to prevent clickjacking (e.g. via invisible iframe) without actually banning frames. There are useful applications for framing another site that can't be achieved by any other means, apart from writing a browser extension. And framing a site without making it invisible seems like unfortunate collateral damage.

Re:How widely used are security-based HTTP response headers? by hannob on Sunday August 30, 2015 @03:01PM (#10144177)
Re:How widely used are security-based HTTP response headers? by Scott_Helme_ on Sunday August 30, 2015 @06:01PM (#10144616)
It's worth pointing out that you can replace the functionality of the X-Frame-Options header with Content-Security-Policy using the frame-ancestors directive if you want to: https://scotthelme.co.uk/csp-cheat-sheet/#frame-ancestors

A world with opt-in to unsafe behaviour would be great, but a long way off I fear. Thanks for mentioning the header check service!

Re:How widely used are security-based HTTP response headers? by eli on Sunday August 30, 2015 @10:37AM (#10143423)
Some day that will probably happen, but of course the issue is that it would break every site that relies on the less secure behavior.
Re:How widely used are security-based HTTP response headers? by idlewords on Sunday August 30, 2015 @03:01PM (#10144179)
CSP breaks bookmarklets in Firefox, which makes it rather user-hostile. This is properly Mozilla's fault, but they've shown no interest in fixing it.

https://bugzilla.mozilla.org/show_bug.cgi?id=866522

Re:How widely used are security-based HTTP response headers? by Scott_Helme_ on Sunday August 30, 2015 @06:27PM (#10144657)
Interesting, I don't use Firefox enough to have noticed this. Would it be possible to whitelist this functionality in your CSP in the short term without adversely affecting the strength of your policy?
Re:How widely used are security-based HTTP response headers? by hyperpape on Sunday August 30, 2015 @08:06PM (#10144858)
Idlewords runs Pinboard, a bookmarking site, so I'm guessing he's worried about the impact of other people turning on CSP. I don't use Pinboard, but I believe I've encountered the problem using the Instapaper bookmarklet.
Re:How widely used are security-based HTTP response headers? by jacquesm on Sunday August 30, 2015 @12:44PM (#10143767)
HN uses x-frame-options:"DENY" to good effect which takes care of a fair number of click-jack tricks, it also uses strict-transport-security.

But there is only so much you can do with headers, the real risks are in the documents themselves.

How about a <nojs> </nojs> pair in the primary document disabling any kind of javascript execution in the space between the tags. And those tags should only work in the primary document.

Re:How widely used are security-based HTTP response headers? by dantillberg on Sunday August 30, 2015 @12:55PM (#10143802)
> How about a <nojs> </nojs> pair in the primary document disabling any kind of javascript execution in the space between the tags.

But wouldn't folks still be able to inject scripts by just writing `</nojs><script>alert('hi')</script><nojs>`?

Re:How widely used are security-based HTTP response headers? by JoshTriplett on Sunday August 30, 2015 @12:57PM (#10143811)
CSP does exactly that; you can just ban inline scripts entirely.
Re:How widely used are security-based HTTP response headers? by martinrue on Sunday August 30, 2015 @09:29AM (#10143227)
For people using Node/Express, Helmet is a useful little library that lets you add these security headers and CSP pretty easily: https://github.com/helmetjs/helmet
Re:How widely used are security-based HTTP response headers? by gkop on Sunday August 30, 2015 @01:05PM (#10143837)
This is the counterpart for Ruby: https://github.com/twitter/secureheaders
Re:How widely used are security-based HTTP response headers? by thephyber on Tuesday September 01, 2015 @07:29PM (#10156514)
Lusca[1] is the NPM module for use with Express that comes in the KrakenJS middleware (open sourced by PayPal).

    app.use(lusca.csrf());
    app.use(lusca.csp({ /* ... */}));
    app.use(lusca.xframe('SAMEORIGIN'));
    app.use(lusca.p3p('ABCDEF'));
    app.use(lusca.hsts({ maxAge: 31536000 }));
    app.use(lusca.xssProtection(true));
[1] https://github.com/krakenjs/lusca
Re:How widely used are security-based HTTP response headers? by dantillberg on Sunday August 30, 2015 @01:43PM (#10143974)
This post encouraged me to go through my own website and add a moderately strict CSP header, sans 'unsafe-inline' scripts/styles. Thanks!
Re:How widely used are security-based HTTP response headers? by Scott_Helme_ on Sunday August 30, 2015 @06:06PM (#10144626)
If you like, you could also add reporting to your CSP and get live feedback on it with https://report-uri.io

It's free to sign up and use.

Re:How widely used are security-based HTTP response headers? by nly on Sunday August 30, 2015 @10:31AM (#10143411)
I've found HPKP and HSTS easy to trivial, but gave up on deploying CSP. It's major refactoring when so much stuff directly includes 3rd party CSS and script, or just injects static CSS and JS in to pages inline.
Re:How widely used are security-based HTTP response headers? by lol768 on Sunday August 30, 2015 @04:10PM (#10144346)
You might find the Content-Security-Policy-Report-Only header useful for identifying CSP issues and deploying policies without actually blocking anything.
Re:How widely used are security-based HTTP response headers? by JoshTriplett on Sunday August 30, 2015 @12:36PM (#10143748)
> It's major refactoring when so much stuff directly includes 3rd party CSS and script, or just injects static CSS and JS in to pages inline.

You can still use CSP, and whitelist specific third-party domains. (There's no way to whitelist inline code, though, and if there were it'd be more work than eliminating it and moving it to files.)

But the refactoring is well worth doing. By eliminating inline JavaScript and off-domain JavaScript, you eliminate the possibility of script injection. And directly including third-party JavaScript (or CSS, which can include JavaScript) opens you up to various kinds of attacks.

Re:How widely used are security-based HTTP response headers? by jacobparker on Sunday August 30, 2015 @01:20PM (#10143891)
> There's no way to whitelist inline code

That's not completely true - the nonce attribute (specify a nonce in the CSP header, have nonce=that on every script tag) or by sending the hashes of the inline scripts upfront in the CSP header.

It doesn't give you inline code in attributes (e.g. onclick) but it's a big help for migrating.

Re:How widely used are security-based HTTP response headers? by JoshTriplett on Sunday August 30, 2015 @03:38PM (#10144259)
Ah. I hadn't found that in Mozilla's CSP documentation. Thanks.
Re:How widely used are security-based HTTP response headers? by Scott_Helme_ on Sunday August 30, 2015 @06:12PM (#10144639)
I'm going to be doing some blogs in the coming weeks on how to use hashes and nonces to whitelist inline script. Hopefully, this will make introducing CSP a little easier. I also have some tools in the making that will help in this regard too.
Re:How widely used are security-based HTTP response headers? by A010 on Sunday August 30, 2015 @11:43AM (#10143598)
I gone through his previous blog post and found the changing Server: header field. Why have to waste time for rebuilding nginx from source for that? Why not just insert 'server_tokens off' in your nginx.conf?
Re:How widely used are security-based HTTP response headers? by nly on Sunday August 30, 2015 @12:17PM (#10143689)
Because it doesn't eliminate the Server header, "off" will return "Server: nginx". Just one of several "fuck you" features in nginx.
Re:How widely used are security-based HTTP response headers? by Scott_Helme_ on Sunday August 30, 2015 @06:25PM (#10144656)
Sadly nly is right. The only other option to change this is the ngx_headers_more module, but that still requires a rebuild. I suppose that way you at least get a little more functionality for your troubles.
Re:How widely used are security-based HTTP response headers? by nly on Sunday August 30, 2015 @07:32PM (#10144769)
You also need that module to do per URI/path/regex match headers properly, because add_header + location blocks are woefully insufficient thanks to the way they are processed. This is one reason I gave up on CSP under nginx.
Re:How widely used are security-based HTTP response headers? by A010 on Sunday August 30, 2015 @12:35PM (#10143742)
Server: header makes people gone mad?
Re:How widely used are security-based HTTP response headers? by JoshTriplett on Sunday August 30, 2015 @12:53PM (#10143797)
It wastes space, and reveals unnecessary information about your server infrastructure.
Re:How widely used are security-based HTTP response headers? by FooBarWidget on Monday August 31, 2015 @12:46AM (#10145468)
As if turning it off helps. Nginx is so popular, attackers would just try Nginx-specific exploits right after trying Apache ones even if they don't know for sure whether you are running Nginx.
Re:How widely used are security-based HTTP response headers? by jasonlfunk on Sunday August 30, 2015 @09:21PM (#10144980)
Can you help me understand the graphs? What is being plotted on the X axis?
Re:How widely used are security-based HTTP response headers? by cbr on Sunday August 30, 2015 @11:50PM (#10145339)
I think popularity, from most to least?
Re:How widely used are security-based HTTP response headers? by Scott_Helme_ on Monday August 31, 2015 @04:08AM (#10145928)
Yes, sorry that wasn't clear. I scanned the sites in groups of 4,000. The x axis is each group in descending order from the top of the Alexa list to the bottom.
Re:How widely used are security-based HTTP response headers? by greggman on Monday August 31, 2015 @06:01AM (#10146118)
I'd really like to know if any of you have used the report feature. It seems like any report you got would show you a bug in your code. What were the bugs? How many reports did you get?
Re:How widely used are security-based HTTP response headers? by Scott_Helme_ on Monday August 31, 2015 @07:24AM (#10146300)
To be honest, most of the reports I get for my sites aren't legitimate issues. Malware on the endpoint makes changes to pages (like inserting ads) that generate reports, certain browser features trigger changes that cause reports. There are also browser plugins and addons that make changes which also cause reports to be sent. You can always create a report only CSP which will send reports but not block actions on the page and use my service at https://report-uri.io to gather the reports for you to look at them. All free and no risk of breaking anything, if you're interested.