CSP and form data: same-origin submission is only the first hop

Started by Anoncto@anoncto••0 views•1 replies
A
Anoncto@anoncto
VIP
19
0
#1

Blocking JavaScript is not the same as keeping form data on-site. A form can submit to an allowed URL, turn its values into query parameters, and leave a later document to leak that URL. No script gadget required.

PortSwigger's self-posting form demonstration, published 11 November and updated 16 November, makes this distinction nicely. The updated article also credits Rafał Wójcicki (AFINE) with finding the technique.

Follow the data, not just the form destination

The demonstration has an unescaped reflected-HTML parameter and a CSP containing default-src 'none' and form-action 'self'. The reported chain is:

  1. Inject a form into the vulnerable page. With no explicit action or method, it submits back to that page using GET. The user still has to submit it.
  2. Serialize the values into the URL. A form control named after the vulnerable parameter carries a second-stage HTML fragment alongside the other submitted values.
  3. Parse a second document. The server reflects that fragment as HTML. It contains a referrer-policy meta element selecting unsafe-url, plus a meta refresh to an external destination.
  4. Leak through the next request's Referer. In the reported demonstration, that request includes the previous document's query string.

The form did not submit directly to the external destination. The second document and its later navigation are the important extra hops.

Two easy-to-miss distinctions

default-src is not a universal fallback. MDN's form-action documentation says this directive has no default-src fallback. Omitting form-action and explicitly permitting same-origin forms are different configurations; the demonstration uses the latter.

A URL password component is not a query parameter called password. The Referrer Policy standard's unsafe-url definition sends a full URL stripped for use as a referrer, including cross-origin. Its stripping algorithm removes the URL's username/password components and fragment. Path and query are additionally removed when stripping to an origin. Renaming a form field does not change that URL structure.

That is why “passwords are stripped from referrers” is the wrong reassurance here: a submitted value in the query is not the password part of https://user:pass@example.test/.

What a useful review should establish

For an authorized lab check, use a harmless marker and trace:

  • whether the injection becomes an actual form and the submission is accepted;
  • whether the marker appears in the resulting query string;
  • whether the second response parses the injected fragment;
  • the effective referrer policy and the outgoing request, not merely a CSP console message.

The article does not name a browser build; don't assume the same result under every sandbox and referrer-policy combination.

My takeaway: fix the HTML-injection sink, keep secrets out of GET URLs, and treat referrer controls as a separate layer. form-action 'self' answers where a form may submit; it does not establish what happens to the submitted data afterward.

For anyone comparing browser behavior, which browser/build and response Referrer-Policy combination stops that second document from sending the query cross-origin? The interesting evidence is the effective policy and captured request at that hop.

0

Join the conversation!