Skip to content

Accessible autocomplete requires style-src 'unsafe-inline' and 'unsafe-eval' to work on pages protected by Content Security Policy (CSP) #398

Open
@alexbishop1

Description

@alexbishop1

The accessible autocomplete does not seem to play very nicely with Content Security Policy (CSP), specifically the style-src directive:

  1. On iOS browsers, it sets style attributes on elements, which is blocked by the style-src directive unless 'unsafe-inline' is specified
  2. It uses the cssTextsetter as part of a function to detect support for pointer events, which is blocked by the style-src directive unless 'unsafe-eval' is specified (curiously, only some browsers seem to report CSP violations for this)

Therefore, using the accessible autocomplete on pages protected by CSP only works if one allows 'unsafe-inline' and 'unsafe-eval' as style sources, which reduces the protection offered by CSP.

This was discovered when trying to apply CSP to GOV.UK Pay’s enter card details page, which uses the GOV.UK country and territory autocomplete, which is built on the accessible autocomplete component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working the way it should (including incorrect wording in documentation)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions