Skip to content

fix(csp): allow Plain widget and disable Zod JIT in Connect UI#6696

Merged
macko911 merged 3 commits into
masterfrom
matej/nan-6012-nan-006-oneleet-pentest-finding-lack-of-content-security
Jul 7, 2026
Merged

fix(csp): allow Plain widget and disable Zod JIT in Connect UI#6696
macko911 merged 3 commits into
masterfrom
matej/nan-6012-nan-006-oneleet-pentest-finding-lack-of-content-security

Conversation

@macko911

@macko911 macko911 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Problem

The report-only CSP rollout on the front-end distributions (NAN-6012; infra in nango-infra#165) surfaced two violations on dev that would break under enforcement:

  • the Plain support widget (dashboard "Help") is blocked, and
  • the Connect UI's Zod validation trips script-src via new Function.

Solution

  • server: add Plain origins (*.cdn-plain.com for script/font, *.plain.com + wss://*.plain.com for connect) to the helmet CSP, mirroring the CloudFront policy so self-hosted/API stay in sync.
  • connect-ui: z.config({ jitless: true }) disables Zod v4's JIT validator (which compiles with new Function). The non-JIT path is functionally identical, so the Connect UI keeps script-src 'self' with no 'unsafe-eval'.

Fixes NAN-6012

Testing

@linear-code

linear-code Bot commented Jul 6, 2026

Copy link
Copy Markdown

NAN-6012

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Confidence score: 3/5

  • In packages/connect-ui/src/main.tsx, z.config({ jitless: true }) is initialized after static imports, so schemas created via App -> routes -> Go can still trigger CSP unsafe-eval before jitless is active; in strict CSP environments this can cause runtime failures or blocked script execution. Move jitless initialization to run before any Zod-using imports (or defer those imports until after config) and verify with a CSP-enabled startup test before merging.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/connect-ui/src/main.tsx">

<violation number="1" location="packages/connect-ui/src/main.tsx:11">
P2: CSP `unsafe-eval` can still occur because `z.config({ jitless: true })` runs after static imports are evaluated, while Zod schemas are created in modules loaded through `App -> routes -> Go`. Initializing jitless in a side-effect module imported before `App` (or another guaranteed earliest entrypoint) would make this reliably effective.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/connect-ui/src/main.tsx Outdated
macko911 added 3 commits July 7, 2026 10:16
Add *.cdn-plain.com (script/font) and *.plain.com + wss://*.plain.com
(connect) to the helmet CSP so the Plain support widget isn't blocked.
Mirrors the CloudFront policy for the front-end distributions.
Zod v4's JIT validator compiles with `new Function`, tripping the
Connect UI's `script-src` (report-only today). `z.config({ jitless:
true })` uses the identical non-JIT path, so `script-src 'self'` needs
no `'unsafe-eval'`.
ES modules evaluate all imports before the importing module's body, so
the inline `z.config()` ran after App's schema modules were already
loaded. Move it to a side-effect module imported first, so jitless is
set before any Zod schema in the App tree is created.
@macko911
macko911 force-pushed the matej/nan-6012-nan-006-oneleet-pentest-finding-lack-of-content-security branch from b939fa1 to f5197f6 Compare July 7, 2026 08:17
@macko911
macko911 marked this pull request as ready for review July 7, 2026 08:33
@macko911
macko911 requested a review from pfreixes July 7, 2026 08:42
@macko911
macko911 added this pull request to the merge queue Jul 7, 2026
Merged via the queue into master with commit 6e398d2 Jul 7, 2026
32 checks passed
@macko911
macko911 deleted the matej/nan-6012-nan-006-oneleet-pentest-finding-lack-of-content-security branch July 7, 2026 11:15
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.

2 participants