A new security header: Feature Policy
scotthelme.co.uk
scotthelme.co.uk
Most security headers exist to enhance site security. This "security header" seems to exist solely to save site operators the trouble of having to vet what third party resources do (mostly ads I assume).
They seem to want to have their cake and eat it too (i.e. embed toxic content, without vetting it, while also disabling many of the more toxic tricks). Problem with that is that toxic ads pay more BECAUSE they're toxic, that's why you went with that ad network, higher CPM.
How about you just do your job as a site owner and employ an ad network with a code of conduct/morals? Not to mention that this won't work, because real sites actually need some of these features.
So unless you know of a way to force site operators to act against their best interests to service yours, I would much rather that we at least have this option available.
Also, let's not forget that Google itself has been guilty of letting toxic ads slip through their vetting procedures. It's not as though there's some 100% foolproof way of ensuring that you only ever run ads that are completely benign in every possible sense without doing away with 90% of the things legitimate advertisers demand to have (rich ads, tracking, javascript, etc), so again, unless you've discovered a realistic way for site operators to fund the operation of their sites without having to erect paywalls, the threat of toxic content will always exist.
You seem confused about this proposal. This doesn't provide the end user any more options, and isn't meant to.
This is a proposal designed to allow site operators to embed dangerous content without vetting that content. Nothing more, nothing less.
Aside from disabling misuse of features, it also uses the Reporting API [0] which means that toxic ads violating the feature policy can be reported to the site owner and then potentially removed. That's what I would do if I were a site owner pushing ads -- check on my side to make sure they aren't doing anything questionable and address it immediately if it is.
> How about you just do your job as a site owner and employ an ad network with a code of conduct/morals?
How would this prevent a bad actor from making an ad that looks safe but isn't?
A great example would be a website with webcam and audio abilities like a conferencing site. You might have 3rd party tools embedded like newrelic or sentry.io for client-side error detection and performance monitoring. Those scripts should NEVER access the webcam or microphone. But what if one of those sites get hacked? Your users have already approved the webcam and mic access to your site, after all its a conferencing tool. But now the hacked sentry script can also link into the webcam and microphone and send that data wherever they like. The client won't see anything different. They approved the access to their microphone and mic already, they won't see anything different. If you used this new header, you have another layer of defense against the hacked scripts. You can define that only scripts from your domains should have access to the microphone and mic, and the browser will deny access to the 3rd party. Beyond that, it also supports reporting, so you can get notifications that newrelic was trying to access users webcams and can enable your incident response team to begin their work responding to the hacked 3rd party.
The kind of controls you're describing would difficult to implement, since there are probably dozens of roundabout ways a script could modify the page to trick it into executing code without it being clear that the third-party script is the reason for that code executing. (For example, what if my evil script redefines `console.log`, and then your first-party script calls that?)
The very idea of a sandboxed third-party script running in the same context as first-party code is, IMO, contradictory.
Your previous comment however was talking about a situation where your conferencing site needs access to the webcam and mic. In that situation, you _have_ to specify the "self" permission for `camera` and `microphone`, in which case any script embedded in your page (regardless of where you loaded it from) also has access to those features.
I see nothing in the original article suggesting otherwise ('origin' refers to the origin of the browsing context, not the origin the script was loaded from). If the article _does_ say otherwise, then the article is wrong. The Feature Policy spec ( https://www.w3.org/TR/CSP3/ ) refers to "browsing contexts", not "the origin a particular script was loaded from".
Test 1:
* Feature-Policy "microphone https://example.com"
* Javascript that accesses microphone hosted on example.com
* Everything loaded and worked as expected
Test 2: * Feature-Policy "microphone https://example.com"
* Javascript that accesses microphone hosted on 3rd-party.com
* Everything loaded and worked - not as expected
I definitely didn't understand this new header. I still see how its useful, but not quite as robust as I had expected.These headers can serve the same purpose: to add an extra layer of prevention, just in case. However well you may vet any 3rd-party content embedded on your pages, you cannot prevent a mistake from their side, at the very least. Let alone any outbreak of malicious code, because 3rd-parties' security is also necessarily imperfect.
A presence of such a layer additionally disincentivizes attempts to add malicious / treacherous content, because it will just not get through.
They say that good security is not like an eggshell, but like an onion.
Military aircraft personnel, and pilots and passengers of very light civil aircraft (think Cessna), do wear them.
</offtopic>
> Not to mention that this won't work, because real sites actually need some of these features.
It works like the CSP header already works, so it's origin-based.
And if the ad network suddenly changes their policy without notifying you, what are you supposed to do?
Because you can't proxy the ad network (because then the ad network doesn't know which ads to serve, since they lose info on the origin request) there are two ways to deal with this: either continuously monitor your third party providers for malfeasance, or sandbox them. Isn't a sandbox better?
That's a legal question, not a technical one.
If another company violates your contract with them, or the contract doesn't require notification for substantial contractual changes then you need to talk to your lawyers.
So we should just, what, pass a law that it's illegal to listen to traffic if you're not law enforcement with a warrant, and then we don't have to encrypt any of our traffic anymore?
Who needs technical solutions when we have legal ones?
(internet-required-explicit-sarcasm-notice)
A better analogy would be, that app developers are too apathetic to review their own app's permissions, so they want a way to limit what permissions a third party ad library could add to their app.
It is a way for people shirking responsibility for their own site, app, or content.
_Should_ users perform a through investigation of every app they install, checking that it does exactly what they expect and no more? Perhaps; but that's not really practical.
The same applies for developers. Should these sites review the source code of every ad they embed in an iframe, whitelisting each ad individually? Maybe, but that's not going to happen. The other commenters are right, what you're suggesting is fantasy, not pragmatic reality.
Permissions systems are better, because they prevent misbehavior even when manual review fails.
It absolutely matters.
Users should have minimal responsibility while consuming content. Site owners should have major responsibility while providing content.
> Should these sites review the source code of every ad they embed in an iframe, whitelisting each ad individually?
They absolutely should know who their ad platform is, what their policies are, and what is/isn't acceptable for an ad hosted by that platform. If their ad platform falls short, they should shop around for a better alternative.
... Or you could choose a wholesome ad network (if such a thing exists), AND limit what features they can access just in case something goes awry and a malicious ad somehow makes it through.
That's like suggesting users not use the app store anymore because sometimes malware slips through the review process.
All major ad networks will occasionally have ads which violate their written policies. Google, for example, bans millions of ads every year for that reason ( https://www.blog.google/technology/ads/how-we-fought-bad-ads... ). The solution to that isn't to just ditch those ad platforms entirely.
As a user I couldn't care less about the hardships of the site owner.
Do you give every user and process on your machine root access? After all, if you trust them, then why restrict them? And if you don't trust them, why let them login / execute at all?
In reality, trust can only ever be partial, and even honest actors can cause damage accidentally, or can be compromised by 3rd parties through no fault of their own. Permissions are how you overcome partial trust: You grant actors only those permissions to act in ways related to the task you want them to do. That way, if even if they are dishonest or compromised, the damage they can do is limited. This principle is the cornerstone of modern security. It's the only way that most systems can interact at all.
It is isn't "apathetic" for apps or websites to restrict the permissions of ads. It's apathetic not to. It's the same apathy that causes users to click through warning screens and grant apps whatever permissions they want, even when a Sudoku game is requesting access to their microphone and camera.
When I worked on Google Reader, something like this would have been incredibly useful. At the time, the only truly safe way to handle embed/object/iframe in post content was to completely filter it out. That's pretty terrible for usability, though. We ended up having a exceptions in our HTML sanitizer embeds of content from certain sites (eg: elves of popular video sites like YouTube and Vimeo were allowed).
I always hated that solution because it made us vulnerable to any site in the whitelist (whether because they become malicious, or because they themselves have a vulnerability), it was unfair to smaller/newer sites, and it was a additional maintenance burden.
In my Copious Free Time (TM) I am trying to write a web framework that is default deny instead, so even if the web itself is whitelist based, you can try to write in a default-deny environment for security reasons. But even if imagine a perfect such framework from 2017, now in 2018 you have these new headers to deal with, and it means even if the 2018 version of this default-deny framework comes up, you can't just upgrade the framework itself and do nothing because now if you default-deny all of these the website stops working. Plus it's a sense of false security if you program this restriction that says "no iframes!" if someone uses a browser that doesn't support it.
It's a hard problem, unfortunately.
Older sites could continue to function as they do today or perhaps be even more heavily sandboxed AND not have access to new APIs.
I also wonder if this will lead bad actors to scan for this header and start targeting their ads at sites that don't have this policy configured.
It really does seem incredibly poorly thought out.
For example, imagine your site relies on document.write to function, and there's currently no feature policy that lets you whitelist that feature. You create a whitelist that includes the features you do use, but that list doesn't mention document.write, because there's currently no way to block or allow that with a feature policy. Now imagine Chrome adds a feature policy for document.write six months later; your site will break because you didn't explicitly whitelist document.write, even though that would have been impossible for you to do at the time your site was first created.
These "security flags" could be added for almost anything that might annoy a user; it's not just for security.
Yes, if it's playing audio not initiated by the user.
> These "security flags" could be added for almost anything that might annoy a user; it's not just for security.
Good. I'm a user and I don't like being annoyed. It's… annoying.
> If you going to take the same approach moving forward then I will simply ignore anything invented by google/chrome, if I realise that after 2 years it will probably be dead due to lack of adoption, waste of my time to invest in anything that has a 2 year shelf life.
Feature Policy is a tool which, though I value, I don't see high hopes for because of the precedent set with HPKP. I'm on the fence with implementation solely because Google's unwillingness to invest in the success of their development platforms is now adversely impacting their security team.
And that breaks my heart.
You're not wrong, but what you want doesn't work for human reasons.
Suppose if these security changes would slowly get imposed over all https traffic in a coordinated fashion among the major browser vendors over a large time span? https requires some periodic maintenance anyway, so it shouldn't add an unreasonable workload.
I worry that this isn't happening because the ad industry (including Google) doesn't want to take responsibility over distributing untrustworthy and insecure code.
> distributing untrustworthy and insecure code.
So this isn't really how things are, we didn't have the ability to fine-tune these access control features before. Either you accepted a website as a whole to give you notifications or not. On the client side it still appears the same, but on the server side they can limit which scripts/domains actually get those permissions.
I'm sure there's a reason for the design (allowing deny all at the top and then only allowing what's specifically needed is nice), but I'm not sure what it'll actually do for the case where an iframe is just a copy/paste embed and can use the allow attribute for whatever it wants.
I think this needs to be rephrased. The site/page shouldn't be deciding what features it can use, it should be indicating what features I might ask permission to use.
I can see the benefit of saying "I might ask to vibrate or use your location but deny any other requests" but this should only be used as a whitelist in the sense that those are the features that the users should be asked for permission to use.
Rather, this seems more like an anti-annoyance header; it lets sites and server administrators restrict the behavior of content they're serving to ensure it doesn't annoy the user. The most obvious use case is for ads: a site could, for example, specify that ads are _not_ allowed to play audio; and the user agent would enforce that.
Not sure how relevant such detailed settings really are... Could be a tool for site operators to somewhat limit issues with bad ads getting through?
I think that the document itself should have knowledge about its security requirements (the "allow" field in <iframe> tags requires this), so it seems awkward to have part of the responsibility in the HTTP server and another part in the HTML document.
I'm sure there are other examples of HTML specific HTTP headers that can't be specified as meta tags because we're still stuck with a lot of crud, but that doesn't mean they're not out of place too. It's just the wrong layer for that data.
I've had iframes completely disabled in uBlock Origin for years now and the only time I've found it "breaking" ("fixing" from my perspective) things is when sites do something like third-party run sweepstakes. I think we'd be better off just breaking iframes now for the sake of our children, like we did with Flash et al. Start off with "click to activate iframe" with harsh warnings, then completely remove support shortly after. There are better solutions for sites that are using it for legit reasons.
I'll give you a hint: both HTML and HTTP share an HT.
Here is the initial Bugzilla issue: https://bugzilla.mozilla.org/show_bug.cgi?id=679966
[0]: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/v...
Is this supposed to mean "notify"?
Also [1] doesn't return the most ideal results.
[1] https://www.google.com/search?q=site%3Asecurityheaders.com+v...
That seems really quite early. Give it some time, let people discuss it.