Repository navigation
fix(security): render step info as text; add CSP and anti-framing headers - #107
Merged
Merged
Conversation
…ders Step info: StepsTimeline parsed a step's `info` as HTML after DOMPurify. That blocked scripts, but still let through forms, password inputs, inline styles (e.g. a full-screen overlay) and protocol-relative links, so anyone with an API token for a team could show teammates or admins a fake "session expired" form that posted off-site. Step info is now rendered as text, and only http(s) URLs become links, built as React elements with rel="noopener noreferrer". Headers: a new src/proxy.js sets, on every page: - a Content-Security-Policy with a per-request nonce (Next.js applies it to its own scripts; RuntimeConfigScript reads it from x-nonce). connect-src is the API origin from ANGLES_API_BASE_URL at runtime. form-action 'self' means no form can submit off-site. - frame-ancestors 'none' and X-Frame-Options: DENY, so the UI cannot be framed for clickjacking. - X-Content-Type-Options: nosniff and Referrer-Policy. Styles keep 'unsafe-inline' because rsuite and ApexCharts set inline styles at runtime, which a nonce cannot cover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KgQXSUjuLVXmLWxobnMfSf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two findings from the security review: HTML injection in step text, and no clickjacking or security headers. The API half of the headers fix is in AnglesHQ/angles (same branch name).
Step info is rendered as text (
StepsTimeline.js)Before: a step's
infowas parsed as HTML after DOMPurify. That blocked scripts, but still let through forms, password inputs, inline styles (for example a full-screen fixed overlay) and protocol-relative links such as//evil.example. Anyone with an API token for a team, including a CI job, could show teammates or admins a fake "session expired, re-enter your password" form that posted off-site.Now:
infois rendered as text, so HTML in it is shown and never interpreted. Onlyhttp(s)URLs become links, built as React elements withtarget="_blank" rel="noopener noreferrer".Behaviour change: results that deliberately sent HTML for formatting (bold, lists) now show the raw tags.
Security headers (
src/proxy.js)Every page now gets:
RuntimeConfigScriptreads it fromx-nonce. Scripts injected into a page don't run.'unsafe-eval'is added in development only.connect-srcis'self'plus the API origin fromANGLES_API_BASE_URL. It's read at runtime, which is why this lives in the proxy rather than innext.config.mjs.img-src 'self' data: blob:,media-src 'self' blob:(screenshots and attachment viewers),object-src 'none',base-uri 'self'.form-action 'self': no form can submit off-site. This is a second line of defence for the step-info issue above.frame-ancestors 'none'.style-srckeeps'unsafe-inline', because rsuite and ApexCharts set inline styles at runtime, which a nonce can't cover.X-Frame-Options: DENY, for browsers that predateframe-ancestors.X-Content-Type-Options: nosniffandReferrer-Policy: strict-origin-when-cross-origin.Static chunks, images and public assets are excluded from the proxy.
Testing
npm run buildpasses, andnext startsends the new headers.With a production build against a running API, I browsed every page in Chromium:
Zero CSP violations, zero page errors, login works, and the runtime config is present.
On a temporary local merge with feat(attachments): show test attachments on the execution #106 (attachments), the video, image, HTML snapshot, log and HAR viewers all work under the policy with zero violations. The HTML snapshot iframe inherits the policy, so its external resources are blocked too.
Embedding the UI in an iframe from another page is refused.
Posted the review's phishing payload as step info: the page renders it as text, with no form or inputs, and only the real
https://URL becomes a link.Follow-up
dompurifyandhtml-react-parserare now unused. Removing them makes this npm version rewrite unrelated"peer"metadata acrosspackage-lock.json, so that's left for a separate cleanup PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01KgQXSUjuLVXmLWxobnMfSf
Generated by Claude Code