You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Artifact upload size enforcement should abort the streaming multipart parse as soon as a request exceeds the configured BGSTM_ARTIFACT_MAX_BYTES. Oversized uploads should be cut off as early as possible — not only after the full body has been buffered to disk by Starlette / python-multipart.
Background
As of PR feat(#298): artifact upload endpoint + pluggable storage backend #319, the /external-results/artifact endpoint applies the size limit after FastAPI/Starlette has parsed the full multipart body, so oversized uploads are only rejected after fully receiving and spooling to a server-side temp file. This leaves a DoS vector open (attackers can tie up disk/spool space even if the handler's in-code check is correct).
The current "partial-write before 413" test does not distinguish buffer-then-reject from true streaming abort — it passes against either implementation.
Production deployments should still use a reverse proxy or WAF as first-line defense (client_max_body_size in nginx, LimitRequestBody in Apache, etc.) — but DoS-class uploads should not reach handler code if avoidable.
Goal
Artifact upload size enforcement should abort the streaming multipart parse as soon as a request exceeds the configured
BGSTM_ARTIFACT_MAX_BYTES. Oversized uploads should be cut off as early as possible — not only after the full body has been buffered to disk by Starlette /python-multipart.Background
/external-results/artifactendpoint applies the size limit after FastAPI/Starlette has parsed the full multipart body, so oversized uploads are only rejected after fully receiving and spooling to a server-side temp file. This leaves a DoS vector open (attackers can tie up disk/spool space even if the handler's in-code check is correct).client_max_body_sizein nginx,LimitRequestBodyin Apache, etc.) — but DoS-class uploads should not reach handler code if avoidable.Scope
File(...)/Form(...)dependency-injected params to directrequest.stream()body reading using a streaming multipart parser (e.g.streaming-form-dataorpython-multipart's low-levelMultipartParser).case_result_id,kind,filename,file).BGSTM_ARTIFACT_MAX_BYTES— before consuming the rest of the body.kind=otherbypass as before.client_max_body_size(or equivalent) value documented in deploy docs as belt-and-suspenders defense.Out of scope
NotImplementedErrorin this milestone).bgstm:requirementannotation handling — tracked in [v0.2] BGSTMReporter should transmitbgstm:requirementannotations and BGSTM should resolve external→UUID for case-result linking #316.Acceptance criteria
References