Skip to content

Block insecure package URLs by default - #4250

Open
gazarenkov wants to merge 13 commits into
redhat-developer:mainfrom
gazarenkov:file-http-packages-gate
Open

gazarenkov wants to merge 13 commits into
redhat-developer:mainfrom
gazarenkov:file-http-packages-gate

Conversation

@gazarenkov

Copy link
Copy Markdown
Member

Description

Adds security validation to reject file: and http:// plugin package URLs by default. These schemes lack integrity verification and are vulnerable to attacks.

Changes

  • Operator-level validation (pkg/model/dynamic-plugins-reference.go): Validates resolved plugin URLs during reconciliation
  • Fetcher-level validation (pkg/fetcher/fetcher.go): Defense-in-depth validation at runtime
  • Configuration: Added ALLOW_INSECURE_PACKAGE_URLS env var (default: false)
  • Documentation: Updated docs/configuration.md with security best practices
  • Tests: Added security validation tests; updated existing file: protocol tests

Which issue(s) does this PR fix or relate to

https://redhat.atlassian.net/browse/RHIDP-19507

PR acceptance criteria

  • Tests
  • Documentation

How to test changes / Special notes to the reviewer

Container Images

Container images are built and pushed to Quay automatically when relevant files change.
Image links will be posted in a PR comment once the push completes.

@gazarenkov
gazarenkov requested a review from a team as a code owner December 1, 2026 14:31
@gazarenkov
gazarenkov requested a review from kim-tsao December 1, 2026 14:31
Comment thread pkg/fetcher/fetcher.go Fixed
@rhdh-qodo-merge

rhdh-qodo-merge Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Block file: and http:// plugin package URLs by default

✨ Enhancement 📝 Documentation 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Rejects file: and http:// dynamic plugin package URLs unless
 ALLOW_INSECURE_PACKAGE_URLS=true.
• Validates in both operator reconciliation (resolveReferences) and fetcher runtime as
 defense-in-depth.
• Adds the env var to the operator deployment (default false) and documents secure package sources
 and opt-out.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • Reference resolution, catalog naming, OCI mirroring, HTTP fetching and extraction produce one bounded dynamic-plugin package-installation outcome; catalog and fetcher components are propagation hops within that integration.
  • The same package-resolution and fetch path admits content that is later extracted for plugin installation; insecure-source handling broadens admission within this bounded capability rather than creating an independent user capability.
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Compatibility cases

  • Before, supported URL forms used case-sensitive recognition and Name handled URL/local forms.
  • After, security and reference logic is case-insensitive, file and npm-style names are extracted, catalog consumers use those names, and redirects stop.
  • New correctness conditions require consistent naming across catalog duplicate detection, reference matching, direct versus resolved validation, single versus dual configuration sources, mirror rewriting, mixed-case schemes and redirecting downloads.
  • The follow-up adds compatibility behavior for file/npm names and can change duplicate or reference matches; existing validation and fetch branches remain otherwise unchanged.
Potential damage 🔴 High 🩹 Integrity

  • The intended gate blocks insecure sources only after resolveReferences is reached.
  • MergePluginsData returns a sole non-empty configuration unchanged, so a file: or http:// package can bypass validation and reach installation; tampered or unintended content can then enter plugin deployment.
  • Reverting the policy stops new admissions only when the validation path is reached; already installed content requires identification, replacement or cleanup.
  • Correcting the bypass stops future admissions but does not automatically repair installed content.
Sources

config/manager/deployment.yaml[67-68]

            - name: ALLOW_INSECURE_PACKAGE_URLS
              value: "false"
Assessed commit 27a2f05
Diagram

graph TD
  A["Operator reconcile"] --> B["resolveReferences"] --> C{"file: or http:// ?"}
  C -->|No| D["Package accepted"]
  C -->|Yes| E{"ALLOW_INSECURE_PACKAGE_URLS=true?"}
  E -->|Yes| D
  E -->|No| F["Reconcile error"]
  D --> G["Fetcher.FetchWithIntegrity"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Single validation point in the fetcher only
  • ➕ One validator, no duplicated logic
  • ➕ Covers every download path automatically
  • ➖ Errors surface later, at fetch time, not during reconciliation
  • ➖ Operator status would not explain the rejection up front
2. Scheme allowlist with integrity required for https://
  • ➕ Stronger guarantee than blocking two schemes
  • ➕ Matches the docs' claim that https:// is paired with integrity
  • ➖ Larger behavior change for existing https:// users without integrity
  • ➖ Needs a migration path

Recommendation: Keep the two-layer check, since reconciliation gives early, actionable errors and the fetcher catches other paths. Move both copies of validatePackageURLSecurity into one shared helper to avoid drift. The checks use case-sensitive HasPrefix, so consider normalizing scheme case. The docs say https:// should use integrity, but the code does not enforce it; either enforce it or soften the docs. Config-driven scheme rejection is otherwise sound.

Files changed (6) +279 / -10

Enhancement (2) +60 / -5
fetcher.goAdd runtime file:/http:// check in FetchWithIntegrity +22/-0

Add runtime file:/http:// check in FetchWithIntegrity

• Adds validatePackageURLSecurity, which rejects file: and http:// URLs unless the env var is "true". FetchWithIntegrity calls it before any download, as a defense-in-depth check.

pkg/fetcher/fetcher.go

dynamic-plugins-reference.goValidate resolved plugin URLs and treat file: as direct link +38/-5

Validate resolved plugin URLs and treat file: as direct link

• Adds a validatePackageURLSecurity helper with a plugin-specific error message. resolveReferences runs it on every resolved plugin package. IsDirectLink now also returns true for file: URLs. Doc comments are updated to recommend oci:// and https://.

pkg/model/dynamic-plugins-reference.go

Tests (2) +165 / -0
local_test.goSet ALLOW_INSECURE_PACKAGE_URLS in file: protocol tests +10/-0

Set ALLOW_INSECURE_PACKAGE_URLS in file: protocol tests

• Each existing file: protocol test now sets the env var to true with t.Setenv, so those tests still exercise the local-copy path under the new default.

pkg/fetcher/local_test.go

dynamic-plugins-reference_test.goAdd table tests for URL security validation +155/-0

Add table tests for URL security validation

• Adds TestValidatePackageURLSecurity covering each scheme with and without the env var, and TestResolveReferencesWithSecurityValidation covering rejection and acceptance through resolveReferences.

pkg/model/dynamic-plugins-reference_test.go

Documentation (1) +52 / -5
configuration.mdDocument secure package URL formats and insecure-URL opt-out +52/-5

Document secure package URL formats and insecure-URL opt-out

• Reorganizes supported package formats into production and dev/test sections. Adds a Package URL Security section covering the blocked schemes, OLM Subscription and kubectl examples for opting in, and production best practices.

docs/configuration.md

Other (1) +2 / -0
deployment.yamlAdd ALLOW_INSECURE_PACKAGE_URLS env var defaulting to false +2/-0

Add ALLOW_INSECURE_PACKAGE_URLS env var defaulting to false

• Sets the operator container env ALLOW_INSECURE_PACKAGE_URLS to "false", so insecure package schemes are blocked in the default deployment.

config/manager/deployment.yaml

@rhdh-qodo-merge

rhdh-qodo-merge Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Code Review by Qodo


View medium (2)
Remediation recommended
1. Unscoped npm plugins fail catalog import 🐞 Bug ⭐ New
Description
DynaPlugin.Name() treats the leading @ in an @npm: package as a version separator and returns
an empty name. For supported references such as @npm:lodash, catalog processing rejects the
package even though the fetcher can install it.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`DynaPlugin.Name()` returns an empty name for supported unscoped `@npm:` packages, causing catalog imports to fail.

## Fix Focus Areas
- pkg/model/dynamic-plugins-reference.go[346-363]
- pkg/model/dynamic-plugins-reference_test.go[490-515]

## Recommended Fix
Remove the `@npm:` prefix before extracting the package name and version, as the fetcher does. Add tests for prefixed unscoped packages with and without a version.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

2. A final slash blocks file plugin imports 🐞 Bug ⭐ New
Description
DynaPlugin.Name() takes the substring after the last slash in a file: path without removing
trailing slashes, producing an empty name for a directory URL. With insecure URLs enabled, a valid
package such as file:/path/to/plugin/ can be copied by the fetcher but is rejected during catalog
processing.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`DynaPlugin.Name()` returns an empty name for `file:` directory URLs ending in `/`, preventing their catalog import despite the fetcher accepting directories.

## Fix Focus Areas
- pkg/model/dynamic-plugins-reference.go[335-344]
- pkg/model/dynamic-plugins-reference_test.go[469-489]

## Recommended Fix
Remove trailing path separators before extracting the last component of a `file:` URL. Add a test for a directory URL ending in `/`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-04d4587 quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-04d4587 quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-04d4587 quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

@rhdh-qodo-merge

Copy link
Copy Markdown

Important

The /generate_labels command by Qodo was deprecated on the 1st of October 2026 and is no longer available. We recommend switching to the latest Qodo review capabilities. Learn more

@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.53%. Comparing base (cd22fdd) to head (27a2f05).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
pkg/fetcher/fetcher.go 50.00% 1 Missing ⚠️
pkg/model/dynamic-plugins-reference.go 98.27% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4250      +/-   ##
==========================================
+ Coverage   65.08%   65.53%   +0.45%     
==========================================
  Files          52       52              
  Lines        3282     3325      +43     
==========================================
+ Hits         2136     2179      +43     
  Misses       1146     1146              
Flag Coverage Δ
nightly ?
unittests 65.53% <97.14%> (+0.45%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/fetcher/http.go 92.85% <100.00%> (+0.54%) ⬆️
pkg/model/dynamic-plugins-mirror.go 97.36% <100.00%> (ø)
pkg/model/dynamic-plugins.go 86.95% <ø> (ø)
pkg/utils/utils.go 59.61% <100.00%> (+1.19%) ⬆️
pkg/fetcher/fetcher.go 50.00% <50.00%> (ø)
pkg/model/dynamic-plugins-reference.go 94.36% <98.27%> (+1.98%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-0c2b9ff quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-0c2b9ff quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-0c2b9ff quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-26fd1ea quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-26fd1ea quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-26fd1ea quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-96dc43a quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-96dc43a quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-96dc43a quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

Comment thread pkg/fetcher/fetcher.go Fixed
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-1c77312 quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-1c77312 quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-1c77312 quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

Comment thread pkg/fetcher/fetcher.go Resolved
Comment thread pkg/fetcher/fetcher.go Resolved
Comment thread pkg/fetcher/fetcher.go Resolved
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-4991ab6 quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-4991ab6 quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-4991ab6 quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

Comment thread pkg/fetcher/fetcher.go Fixed
…gate

# Conflicts:
#	pkg/model/dynamic-plugins-reference.go
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-c4feeae quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-c4feeae quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-c4feeae quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

Comment thread pkg/fetcher/http_test.go Fixed
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-0dcc894 quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-0dcc894 quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-0dcc894 quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-54ef7ea quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-54ef7ea quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-54ef7ea quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

@kim-tsao kim-tsao left a comment

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.

review comments were addressed, so lgtm on my side. I will hold off on approving until the remaining Qodo findings are addressed

@kim-tsao
kim-tsao self-requested a review December 2, 2026 21:25
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-0897d1a quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-0897d1a quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-0897d1a quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

@sonarqubecloud

sonarqubecloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.2.0-pr-4250-27a2f05 quay.io/rhdh-community/operator:2.2.0-pr-4250
Bundle quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250-27a2f05 quay.io/rhdh-community/operator-bundle:2.2.0-pr-4250
Catalog quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250-27a2f05 quay.io/rhdh-community/operator-catalog:2.2.0-pr-4250

This branch has not been deployed

No deployments
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