Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tee_gateway/controllers/ohttp_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@
_SSE_CONTENT_TYPE = "text/event-stream"

# Cap on the encapsulated request size. The inner payload is a chat-completion
# JSON body; even with long conversation history this comfortably fits in a few
# hundred KB. Rejecting larger bodies up-front prevents a malicious relay from
# forcing the enclave to allocate and attempt HPKE decapsulation on arbitrarily
# large blobs.
_MAX_ENCAPSULATED_REQUEST_BYTES = 512 * 1024
# JSON body and may include base64 image attachments; 16 MiB covers roughly a
# 10 MiB raw image after base64/JSON overhead while still bounding enclave
# memory use for malicious or accidentally huge payloads.
_MAX_ENCAPSULATED_REQUEST_BYTES = 16 * 1024 * 1024

# Fields that can re-identify a client and have no role in inference. We drop
# them before forwarding to the inner handler — keeping them inside the
Expand Down
2 changes: 1 addition & 1 deletion tee_gateway/test/test_ohttp_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def fake_get_tee_keys():

def test_oversized_body_returns_413(monkeypatch):
sk, _ = ohttp.generate_keypair()
# Body is well past _MAX_ENCAPSULATED_REQUEST_BYTES (512 KiB). Werkzeug
# Body is well past _MAX_ENCAPSULATED_REQUEST_BYTES. Werkzeug
# will set Content-Length from the data length, so the up-front check
# fires before any HPKE work.
app, captured, fake_keys = _make_app(lambda: ("200 OK", [], iter([])), sk)
Expand Down
Loading