medialize / medialize/ally.js

Potential CSP violations

Open
#129 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Chrome App discussion
Dominant language
JavaScript
Stars
1.6k
Forks
82
PR merge metrics
No merged PRs in 30d

Description

The CSP (Content Security Policy) can be used on any document to limit the document's scripting ability. caniuse says Chrome and Firefox support this feature already.

The supports tests do things like creating <object src="data:…"> to determine if they're focusable or not and these tests may violate a CSP.


This problem was first spotted by @ryan-ludwig with Chrome Apps, which sport the following (not relaxable) CSP:

Content-Security-Policy:
  default-src 'self';
  connect-src * data: blob: filesystem:;
  style-src 'self' data: chrome-extension-resource: 'unsafe-inline';
  img-src 'self' data: chrome-extension-resource:;
  frame-src 'self' data: chrome-extension-resource:;
  font-src 'self' data: chrome-extension-resource:;
  media-src * data: blob: filesystem:;

The error they observed was:

"Refused to load plugin data from 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zd…V4dCB4PSIxMCIgeT0iMjAiIGlkPSJzdmctbGluay10ZXh0Ij50ZXh0PC90ZXh0Pjwvc3ZnPg==' because it violates the following Content Security Policy directive: "default-src 'self' blob: filesystem: chrome-extension-resource:". Note that 'object-src' was not explicitly set, so 'default-src' is used as a fallback."

The problem in this particular case is that the directive object-src 'self' data:; is missing. See the potential CSP violations below.

CSP directives currently required by ally.js 1.1.0

After running the test suite with Content-Security-Policy-Report-Only the following violations were logged, forming this policy:

Content-Security-Policy:
  default-src 'self';
  style-src 'unsafe-inline';
  img-src data:;
  media-src data:;
  object-src 'self' data:;
  frame-src data:;
style-src: inline

covered by directive style-src 'unsafe-inline';

img-src: data

covered by directive img-src data:;

media-src: data

covered by directive media-src data:;

object-src: data

covered by directive object-src 'self' data:;

above CSP violation reports don't make any sense to me. The reasons are probably:

frame-src: data

covered by directive frame-src data:;

above CSP violation reports don't make any sense to me. The reasons are probably:


We're not the first to face this issue. Angular introduced ng-csp to work around this in lieu of a proper CSP feature detection.

I don't yet know how CSP compliance should be handled by libraries such as ally.js. I'm open to suggestions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the test suite with Content-Security-Policy-Report-Only and review the listed supports, query/focusable.strict.js, and util/node-array.js files. Compare the reported violations with the referenced CSP directives and determine a concrete compliance approach for ally.js. Done should include an agreed scope and tests showing the chosen approach avoids or documents the violations.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
accessibility, frontend, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.