← Back to Pull requests

(#2963) feat(webhook): reject disallowed URL schemes in SparkApplication fetch fields #3019

Open
unknown opened this pull request with 466 lines diff across 5 files
View on GitHub
unknown unknown commented on Jun 26, 2026 18:20 UTC
Author

<!-- 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:

  • Add --spark-allowed-url-schemes webhook flag and matching

  • webhook.sparkAllowedURLSchemes Helm value (default empty: only schemeless,
    file://, local:// pass; add gs, s3a, hdfs, etc. as needed).
  • Check spec.mainApplicationFile, spec.sparkConf (comma-split), and the

  • fetch-capable spec.deps. lists in SparkApplicationValidator.validateSpec.
    spec.deps.packages/excludePackages are excluded (Maven coordinates, not URLs).
  • Fail closed: reject values url.Parse cannot handle and scheme-relative

  • //host/path references that are not local paths.
  • Cover the behavior with unit tests, a deps-field coverage guard, and an e2e

  • rejection/acceptance spec; add a kind-e2e-test Make target.

    Change Category

  • Bugfix (non-breaking change which fixes an issue)

  • Feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that could affect existing functionality)

  • Documentation update
  • 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

  • I have conducted a self-review of my own code.

  • I have updated documentation accordingly.

  • I have added tests that prove my changes are effective or that my feature works.

  • Existing unit tests pass locally with my changes.
  • 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>

    Diff: 466 lines (+349 / -117) across 5 files Reviewer: vjanelle Review duration: 226112m
    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
    0.53
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.6% (MEDIUM) · Higher = larger blast radius
    52.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.1% · Safe to merge
    29.1%