Skip to content

Security: Unbounded memory consumption when buffering S3 object streams#312

Open
tuanaiseo wants to merge 1 commit intojeremydaly:mainfrom
tuanaiseo:contribai/fix/security/unbounded-memory-consumption-when-buffer
Open

Security: Unbounded memory consumption when buffering S3 object streams#312
tuanaiseo wants to merge 1 commit intojeremydaly:mainfrom
tuanaiseo:contribai/fix/security/unbounded-memory-consumption-when-buffer

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

getObject converts the entire S3 response stream into a Buffer via streamToBuffer with no size limit. Large objects can exhaust Lambda memory and cause denial of service if object size is attacker-influenced or not strictly controlled.

Severity: high
File: lib/s3-service.js

Solution

Avoid full buffering for arbitrary objects. Enforce a maximum allowed content length before reading, stream directly to the client/storage when possible, and abort reads when size thresholds are exceeded.

Changes

  • lib/s3-service.js (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

`getObject` converts the entire S3 response stream into a Buffer via `streamToBuffer` with no size limit. Large objects can exhaust Lambda memory and cause denial of service if object size is attacker-influenced or not strictly controlled.

Affected files: s3-service.js

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant