(#2963) feat(webhook): reject disallowed URL schemes in SparkApplication fetch fields #3019
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.53) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.53 · 466 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.368
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #3019"
general
weight: 0.35
vjanelle
<!-- Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, check our contributor guidelines: https://www.kubeflow.org/docs/about/contributing
2. To know more about how to develop with the Spark operator, check the developer guide: https://www.kubeflow.org/docs/components/spark-operator/developer-guide/
3. If you want faster PR reviews, check how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
4. Please open an issue to discuss significant work before you start. We appreciate your contributions and don't want your efforts to go to waste!
-->
Purpose of this PR
spark-submit runs inside the operator pod, so any http/https/etc. URL in a
fetch-capable SparkApplication field (spec.mainApplicationFile, spec.sparkConf
values, spec.deps.{jars,files,pyFiles,archives,repositories}) is dereferenced by
the operator's principal: its ServiceAccount, mounted secrets, Workload Identity
/ IRSA, and VPC reachability. That is SSRF. The validating webhook previously did
not inspect these fields and there was no operator-side knob to restrict them.
This adds an admission-time check that validates the URL scheme of every value in
those fields. Schemeless paths and file://, local:// URIs are always allowed (they
reference local or in-image files the operator never fetches); any other scheme
must appear in the operator's allow list or the SparkApplication is rejected with
an error naming the offending field, scheme, and value. The check is value-based
rather than key-based so it stays Spark-version independent and cannot be silently
bypassed by a newly fetch-capable conf key.
Fixes #2963.
Proposed changes:
webhook.sparkAllowedURLSchemes Helm value (default empty: only schemeless,
file://, local:// pass; add gs, s3a, hdfs, etc. as needed).
fetch-capable spec.deps. lists in SparkApplicationValidator.validateSpec.
spec.deps.packages/excludePackages are excluded (Maven coordinates, not URLs).
//host/path references that are not local paths.
rejection/acceptance spec; add a kind-e2e-test Make target.
Change Category
Rationale
A key-based allowlist drifts as Spark evolves and any miss is a silent bypass;
value-scheme checks are Spark-version independent. The default allows only local
references so the hardening is on by default, while operators opt into the remote
schemes their workloads actually need.
Checklist
Additional Notes
spec.hadoopConf is intentionally out of scope: its values become spark.hadoop.
config consumed by the driver/executor at runtime, not URLs the operator fetches
at submit time, and many are legitimately host/endpoint-shaped. The issue also
notes an exfil vector (spark-submit stderr propagated to Status.ErrorMessage and
Warning events); sanitizing those side channels is tracked separately.
Signed-off-by: Vincent Janelle <randomfrequency@gmail.com>
Co-authored-by: Claude <claude@anthropic.com>