4

In trying to make our application as secure as possible, following best-practice advice and addressing issues flagged by OWASP... We added a Permission-Policy header to our app.

Since there's no way (currently) of simply specifying the functionality that should be allowed, we used permissionspolicy.com to generate a comprehensive list of features to restrict.

Unfortunately, when browsers (specifically Chrome, but possibly others) encounter a feature in this header that they don't recognize, they generate a console warning:

Error with Permissions-Policy header: Unrecognized feature: 'battery'.

(Irrelevant digression... I guess it makes sense that my (desktop) browser wouldn't know what to do with this. I'm guessing that it's a feature present on mobile devices?)

Console warnings aren't the end of the world, but they do add noise and fall foul of the Lighthouse "best practice" audit.

We could remove the offending entries from our policy header, but this seems to run counter to our security objectives - what if someone used a browser that did support a feature we'd removed, and the app was exploited as a result?

So, the question: Is there an established mechanism for having a comprehensive Permissions Policy, without tons of console warnings? For instance, should we sniff the user agent and serve up a policy containing only supported features? Or is there some way of suppressing the warnings even for unrecognized features?

Tom Wright
  • 11,278
  • 15
  • 74
  • 148
  • In my opinion, it is not necessary to add extra complexity to the backend in order to address browser console warnings. The most important aspect is ensuring that correct security headers are being sent, which you are already doing. Over time, browsers may introduce new features that will eliminate these warnings automatically. Also, since you can not fully trust the user-agent request header and maintaining your feature detection mechanism just in time, it doesn’t seem to be a correct way of handling this issue as well. – Murat Çorlu Mar 17 '23 at 13:44

0 Answers0