Skip to content

Modify regex for body size WAF rule - #2281

Merged
stephencdaly merged 1 commit into
mainfrom
allow-oversize-request-body-for-new-file-upload-url
Sep 22, 2026
Merged

stephencdaly merged 1 commit into
mainfrom
allow-oversize-request-body-for-new-file-upload-url

Conversation

@stephencdaly

@stephencdaly stephencdaly commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

We are going to add a separate forms-runner URL for file upload questions, so that we can exempt only this URL from WAF rules that block file uploads (request size, XSS) rather than exempting POST requests for all answer types.

See govuk-forms/forms-runner#2352

Update the regex to allow large request bodies for the new file upload URL. Once the forms-runner change to use the new URL has been deployed we can update the regex to only allow large request bodies for the /upload-file path.

I've tested this on the dev environment before and after applying the related forms-runner change and ensured large files can be uploaded.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Has all relevant documentation been updated?

Reminders

If you've made changes to the deployer role (files in modules/deployer-access):

  • Remember to run make <environment> forms/account apply on the relevant environments (dev, staging and/or prod)
  • Check the #govuk-forms-deployment-notifications Slack channel to ensure the apply-forms-terraform-<environment> pipelines have run successfully

We are going to add a separate forms-runner URL for file upload
questions, so that we can exempt only this URL from WAF rules that
block file uploads (request size, XSS) rather than exempting POST
requests for all answer types.

Update the regex to allow large request bodies for the new file upload
URL. Once the forms-runner change to use the new URL has been deployed
we can update the regex to only allow large request bodies for the
`/upload-file` path.
@stephencdaly
stephencdaly force-pushed the allow-oversize-request-body-for-new-file-upload-url branch from c3eb34f to 649d2e2 Compare September 22, 2026 11:19
@stephencdaly
stephencdaly marked this pull request as ready for review September 22, 2026 11:43
Copilot AI balanced review requested due to automatic review settings September 22, 2026 11:43

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The focused regex change correctly supports both existing and new upload routes during migration.

Review effort: Balanced
Findings: None

What changed in this PR

Updates WAF routing to support the new forms-runner file-upload endpoint while retaining existing upload behavior during rollout.

Changes:

  • Allows optional /upload-file suffixes for file-upload requests.
  • Updates the route comment accordingly.
File Description
infra/​modules/​cloudfront_waf_protection/​waf.tf Extends the permitted file-upload URL regex.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@stephencdaly
stephencdaly added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit 4f7a243 Sep 22, 2026
21 checks passed
@stephencdaly
stephencdaly deleted the allow-oversize-request-body-for-new-file-upload-url branch September 22, 2026 11:58
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.

4 participants