Skip to content

fix(rules): x-frame-options flags unrecognised values and parses frame-ancestors #1080 - #1108

Merged
nc9 merged 1 commit into
mainfrom
fix/x-frame-options-invalid-value-1080
Oct 26, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/x-frame-options-invalid-value-1080

Conversation

@nc9

@nc9 nc9 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Closes #1080

  • Unrecognised X-Frame-Options value (not DENY/SAMEORIGIN after trim, case-insensitive, not ALLOW-FROM) warns naming the value, unless CSP frame-ancestors covers the page (pass via frame-ancestors).
  • Joined repeats (DENY, DENY) are one value; conflicting (DENY, SAMEORIGIN) is unrecognised.
  • frame-ancestors detected as a parsed directive name (split on , and ;, first token), not a substring.
  • Docs + CHANGELOG updated; 20 unit tests.

Gates: new test file, docs tangly check --strict, check-links, glossary --check all pass. Local bun 1.4.3 (pin 1.4.0).

Skill: no change needed. Private follow-up: the instant security headers check in apps/web (private #3121) mirrors the old behaviour and should be updated.

@claude

claude Bot commented Oct 24, 2026

Copy link
Copy Markdown

Reviewed the diff for security/x-frame-options. I found no blocking problems. I didn't run the tests.

  • (low) x-frame-options.ts: a bare frame-ancestors with no sources counts as a pass. The test script-src 'self'; frame-ancestors asserts this. Browsers treat an empty source list as equivalent to 'none', so the pass is arguably right, but a comment saying so would help.
  • (low) x-frame-options.ts: an ALLOW-FROM value still warns even when CSP frame-ancestors is present. This was already the behaviour. The new unrecognised-value branch passes in that case, so the two branches are now inconsistent. Consider making both defer to CSP.
  • (nit) normalizeXfo: DENY, gives the parts ["DENY", ""] and warns. That seems correct, but a test would document it.
  • (nit) The docs and changelog match the code, and the tests cover the new branches well.

@nc9
nc9 force-pushed the fix/x-frame-options-invalid-value-1080 branch from b901935 to 01c5706 Compare October 26, 2026 08:45
@claude

claude Bot commented Oct 26, 2026

Copy link
Copy Markdown

Review of #1108: the logic matches the PR description, and I found nothing that should block the merge. I read the diff only and did not run the tests.

  • (low) packages/rules/tests/security/x-frame-options.test.ts:11: the fixture uses acme.test. AGENTS.md says fixture hosts should be example.com or a subdomain, because .test is treated as a non-public host and takes different code paths. This rule doesn't depend on that, but switch it to be safe.
  • (low) packages/rules/src/security/x-frame-options.ts (hasFrameAncestorsDirective): a bare frame-ancestors directive with no sources passes, and the test script-src 'self'; frame-ancestors asserts that. Browsers treat an empty frame-ancestors as invalid, so this can credit protection that isn't there. This is an edge case, and the old substring check was more permissive.
  • (nit) packages/rules/src/security/x-frame-options.ts: the // eslint-disable-next-line no-control-regex comment is probably dead, since the project uses oxlint. Also, the repo prefers \u escapes, which you already use, so this one is only about the dead comment.
  • (nit) packages/rules/tests/security/x-frame-options.test.ts: checks: any[] sidesteps the avoid any guideline. Type it as CheckResult[].
  • (nit) ALLOW-FROM is still detected with includes on the normalized value, which the PR doesn't change. A value like DENY, ALLOW-FROM x gets the deprecated message rather than the unrecognised one. That is harmless.

The test file sits under packages/rules, so the rules suite should pick it up. I didn't prove the tests fail without the fix, so please confirm that locally.

@nc9
nc9 merged commit 66c0c05 into main Oct 26, 2026
15 checks passed
@nc9
nc9 deleted the fix/x-frame-options-invalid-value-1080 branch October 26, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security/x-frame-options reports nothing for an unrecognised X-Frame-Options value

1 participant