Skip to content

Validate issuer/URL by scheme and host instead of string prefix#62

Merged
lukpueh merged 1 commit into
eclipse-csi:mainfrom
lukpueh:harden-issuer-validation
Jul 1, 2026
Merged

Validate issuer/URL by scheme and host instead of string prefix#62
lukpueh merged 1 commit into
eclipse-csi:mainfrom
lukpueh:harden-issuer-validation

Conversation

@lukpueh

@lukpueh lukpueh commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

is_issuer_known accepted any issuer that started with the expected string "https://ci.eclipse.org". A string-prefix check treats the issuer as opaque text, so URLs that only begin with those characters but resolve to a different host were accepted -- e.g. a userinfo form ("https://ci.eclipse.org@other.host") or a suffix form ("https://ci.eclipse.org.other.host"). The issuer is then used for OIDC discovery, so it must genuinely point at the expected host.

Match issuers/URLs on their parsed scheme and host (f"{scheme}://{hostname}") against a base-URL constant:

  • models.is_issuer_known: compare against JENKINS_ISSUER_BASE_URL, mirroring how the GitHub issuer is matched against GITHUB_ISSUER.
  • cli add-workload: apply the same scheme+host comparison to both the GitHub (GITHUB_BASE_URL) and Jenkins (JENKINS_ISSUER_BASE_URL) cases, replacing the bare netloc equality and startswith checks. This also enforces the https scheme on the GitHub repo URL in the cli. The input to the cli is trustworthy, but it doesn't hurt to check to avoid foot-guns.

Rename the constant JENKINS_ISSUER_PREFIX to JENKINS_ISSUER_BASE_URL and add GITHUB_BASE_URL.

Add tests for the userinfo/suffix host constructions, non-https and malformed issuers, and the disguised/non-https URLs in the CLI (asserting no network call or DB write happens for a rejected URL). Update the authentication flow in DESIGN.md to describe host-based validation.

Assisted-by: Claude Opus 4.8 (1M context) noreply@anthropic.com (reviewed, edited, and signed off by me)

is_issuer_known accepted any issuer that started with the expected string
"https://ci.eclipse.org". A string-prefix check treats the issuer as opaque
text, so URLs that only begin with those characters but resolve to a different
host were accepted -- e.g. a userinfo form ("https://ci.eclipse.org@other.host")
or a suffix form ("https://ci.eclipse.org.other.host"). The issuer is then used
for OIDC discovery, so it must genuinely point at the expected host.

Match issuers/URLs on their parsed scheme and host (f"{scheme}://{hostname}")
against a base-URL constant:

- models.is_issuer_known: compare against JENKINS_ISSUER_BASE_URL, mirroring how
  the GitHub issuer is matched against GITHUB_ISSUER.
- cli add-workload: apply the same scheme+host comparison to both the GitHub
  (GITHUB_BASE_URL) and Jenkins (JENKINS_ISSUER_BASE_URL) cases, replacing the
  bare netloc equality and startswith checks. This also enforces the https
  scheme on the GitHub repo URL.

Rename the constant JENKINS_ISSUER_PREFIX to JENKINS_ISSUER_BASE_URL and add
GITHUB_BASE_URL.

Add tests for the userinfo/suffix host constructions, non-https and malformed
issuers, and the disguised/non-https URLs in the CLI (asserting no network call
or DB write happens for a rejected URL). Update the authentication flow in
DESIGN.md to describe host-based validation.

Signed-off-by: Lukas Puehringer <lukas.puehringer@eclipse-foundation.org>
Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lukpueh
lukpueh requested review from iliescuioana and mbarbero July 1, 2026 13:50
@lukpueh
lukpueh merged commit 1b324c0 into eclipse-csi:main Jul 1, 2026
5 checks passed
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