Skip to content

Admission Webhook: Missing request context propagation and inflexible Content-Type parsing #506

Open

Description

@Rucha0901

Description

In admission/webhook/server.go, the admission webhook server has two issues:

  1. In handleWebhookValidate, the validator is invoked with context.TODO() instead of req.Context(). As a result, if the API server disconnects or times out during validation, the validation cannot be cancelled, wasting CPU.
  2. In parseRequest, the Content-Type header is checked with exact string equality (r.Header.Get("Content-Type") != "application/json"). Requests with standard media type parameters (such as application/json; charset=utf-8) are rejected with 400 Bad Request.

Steps To Reproduce

  1. Send an AdmissionReview request with Content-Type: application/json; charset=utf-8 to /validate.
  2. Notice the request fails with 400 Bad Request.
  3. Observe that incoming request context cancellation does not propagate to validator.Validate().

Expected behavior

  1. The webhook should accept application/json along with optional media type parameters such as charset=utf-8.
  2. The webhook should pass req.Context() to validator.Validate() so cancellation propagates properly.

Actual Behavior

  1. Requests with media type parameters are rejected with 400 Bad Request.
  2. context.TODO() is passed to validator.Validate(), ignoring client cancellation or timeouts.

Activity

  1. Rucha0901 commented on Nov 14, 2026

    @Rucha0901
    ContributorAuthor

    @matthyx ,I am working on this issue and soon will raise a PR .

    please let me know if you have any suggestions.

    thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions