Skip to content

Conversation

@sarahseewhy
Copy link
Contributor

What problem does this pull request solve?

Secure forms-runner from potential unwanted vulnerability scanning by enforcing a list of allowed hosts. Very similar to PR#1803 in forms-runner (see link).

This aligns forms-product-page with how forms-admin and forms-runner configures its config.hosts (see this link).

Note: The list of default host patterns is based on my understanding of how we use the www.forms.service.gov.uk domain. I may be missing some context so do have a look to make sure I've not missed a variation on that domain or added anything which isn't necessary. I've also put the regex patterns through a regex checker just in case.

@sarahseewhy sarahseewhy force-pushed the configure-config-hosts branch from 46a1c63 to 4359582 Compare December 18, 2025 13:42
module HostPatterns
DEFAULT_HOST_PATTERNS = [
/forms\.service\.gov\.uk/,
/www.forms\.service\.gov\.uk/,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/www.forms\.service\.gov\.uk/,
/www\.forms\.service\.gov\.uk/,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Better than the regex checker I used.

Copy link
Member

Choose a reason for hiding this comment

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

Oh and I think we need a regex for environments other than prod:

Suggested change
/www.forms\.service\.gov\.uk/,
/www\.forms\.service\.gov\.uk/,
/www\.[^.*]*\.forms\.service\.gov\.uk/,

@github-actions
Copy link

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-1002.www.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

* Add config.hosts configuration to production and a HostPatterns module
* Add an allowed hosts list based on the `forms.service.gov.uk` domain (there are fewer items on this list because the configuration for `forms-product-page differs slightly from `forms-runner` and `forms-admin`; this list should be sense-checked by another developer)
* This aligns `forms-product-page` with how config.hosts is configured in `forms-admin` and `forms-runner`
@sarahseewhy sarahseewhy force-pushed the configure-config-hosts branch from 4359582 to 901af8b Compare December 18, 2025 13:50
* It looks like forms.service.gov.uk always redirects to www.forms.service.gov.uk
* We don't want requests going to the app from a host header that's just forms.service.gov.uk
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.

3 participants