Support CSP nonces in `workflow inspect runs --web`

Open
#5,192 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Domain
frontend, security

Research direction

Start with startServer(port) in the @workflow/web package, which builds the Express app internally, and with the server-rendered HTML that inlines <script> tags carrying per-request router state. Check how the React renderer is called, since it accepts a nonce but none is passed. The issue leaves open whether to add a nonce option or hook to startServer or to export the Express app, so confirm the direction with a maintainer first. Done means every inline <script> gets the per-request nonce and the page runs under a nonce-based CSP without 'unsafe-inline'.

Written by the indexing model from the issue text.

Description

workflow inspect runs --web serves the @workflow/web app (4.1.21) with no way to run it under a nonce-based Content-Security-Policy.

What happens

  1. workflow inspect runs --web calls startServer(port) from @workflow/web, which builds the Express app internally and does not expose it, so there is no place to add middleware.
  2. The server-rendered HTML contains inline <script> tags that carry per-request router state. Their content differs on every request, so a hash-based script-src cannot allow them.
  3. The React build supports a nonce, but none is passed to it.

Effect

A deployment that requires script-src 'self' with a nonce (for example, a security scan that fails on script-src 'unsafe-inline') has to allow 'unsafe-inline' for scripts and styles in front of the inspector.

Request

Support a CSP nonce in workflow inspect runs --web, for example:

  • an option or hook on startServer that returns a per-request nonce, which the server passes to the React renderer and adds to every inline <script> it emits; or
  • export the Express app so callers can mount their own middleware and pass the nonce themselves.

Happy to open a PR if a direction is preferred.

Dominant language
TypeScript
Stars
2.5k
Forks
401
Avg merge
1d 21h
Merged PRs (30d)
201

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No 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.

More from vercel/workflow

All issues in vercel/workflow

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.