Skip to content

fix: limit request body size #114

Closed

Description

@uniqueg

Found in the pre-release review of dev at 98771b3 (before v0.3.0).

Problem

Request bodies have no size limit, and they are read into memory before the bearer token is checked (Connexion builds the request object, including the body, outside the security decorator). Neither the app config nor FOCA sets Flask's MAX_CONTENT_LENGTH, and the API schemas have no maxLength. The Helm chart runs one replica with a 128Mi memory limit, and /tmp is an emptyDir without sizeLimit.

Impact

An unauthenticated client can make the pod run out of memory (or fill /tmp with multipart bodies) by sending very large request bodies. ingress-nginx limits bodies to 1m by default, but other ingress controllers and the OpenShift Route have no default limit.

Proposed fix

  • Set MAX_CONTENT_LENGTH (e.g. 1 MiB, configurable) on the Flask app, so oversized requests get 413 before any processing.
  • Test that a large body without a token gets 413.
  • Helm chart: set a body-size limit on the Ingress (e.g. nginx.ingress.kubernetes.io/proxy-body-size) and a sizeLimit on the /tmp volume.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions