Skip to content

feat(config): allow self-hosted admins to bypass allowedHeaders - #45654

Open
jamietanna wants to merge 3 commits into
mainfrom
fix/validate-headers
Open

feat(config): allow self-hosted admins to bypass allowedHeaders#45654
jamietanna wants to merge 3 commits into
mainfrom
fix/validate-headers

Conversation

@jamietanna

@jamietanna jamietanna commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Changes

Follow-up to #45649

In a similar way to how allowedEnv works, we should allow a
self-hosted admin to specify whichever headers they wish in their
hostRules - whether in their global config, a repositories[] entry,
or a preset a repositories[] entry extends.

Previously, this would require a self-hosted admin to add any header
they wished to set to allowedHeaders, which would also allow any of
their users' repositories to set that same header.

We can align this behaviour with allowedEnv, which makes sure that the
admin's own headers are always applied regardless of allowedHeaders,
while a repository's own hostRules - and those of any preset it
extends - remain constrained by it as before.

We do not currently allow an extends (without a repositories[]
entry) to bypass, and they'll be followed-up with in #45670.

Context

Please select one of the following:

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Use of AI in replying to PR comments

Who answers review comments:

  • @jamietanna will read and reply directly. Name the account.
  • An agent will draft replies and @username will read them before they are posted. Name the account.
  • Nobody has explicitly committed to replying.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests, but ran on a real repository, or
  • Both unit tests + ran on a real repository

The public repository:

In a similar way to how `allowedEnv` works, we should allow a
self-hosted admin to specify whichever headers they wish in their
`hostRules` - whether in their global config, a `repositories[]` entry,
or a preset a `repositories[]` entry extends.

Previously, this would require a self-hosted admin to add any header
they wished to set to `allowedHeaders`, which would also allow any of
their users' repositories to set that same header.

We can align this behaviour with `allowedEnv`, which makes sure that the
admin's own `headers` are always applied regardless of `allowedHeaders`,
while a repository's own `hostRules` - and those of any preset it
extends - remain constrained by it as before.

We do not currently allow an `extends` (without a `repositories[]`
entry) to bypass, and they'll be followed-up with in #45670.

Co-Authored-By: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
Co-Authored-By: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
@jamietanna
jamietanna marked this pull request as ready for review September 3, 2026 15:10
@github-actions
github-actions Bot requested a review from viceice September 3, 2026 15:11
@jamietanna
jamietanna requested a review from a team September 3, 2026 15:11
Comment thread docs/usage/self-hosted-configuration.md Outdated
For more details on this syntax see Renovate's [string pattern matching documentation](./string-pattern-matching.md).

!!! note
`allowedHeaders` constrains what a repository, and the presets it extends, may set - it does not constrain you, the self-hosted administrator.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This admonition is now bigger then actual text, we should move some info out of it

Comment thread lib/util/host-rules.ts
// set as a pair with `headers`, even to `undefined`, rather than only when there are trusted headers: `findMatchingRule`'s hostType fallbacks build on `find()` with `{ ...fallbackResult, ...res }`, so `res`'s own `trustedHeaderNames` must shadow a fallback's own whenever `res.headers` does the same to a fallback's `headers` - otherwise a fallback's `trustedHeaderNames` could survive alongside `res`'s own, unrelated `headers`
// never set when `res.headers` isn't either, so a `find()` with no matching headers still returns `{}` rather than `{ trustedHeaderNames: undefined }`, which callers that check for an empty result (e.g. `isNonEmptyObject`) rely on
// tracked so that `applyHostRule`'s request-time defence-in-depth knows which of `res.headers` already bypassed `allowedHeaders` at registration as the administrator's own, and does not re-drop them
res.trustedHeaderNames = trustedHeaders

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should only set it if trustedHeaders are there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As in wrapping it in an if (trustedHeaders)?

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