Skip to content

fix(security): 2 improvements across 1 files#1176

Open
andoan16 wants to merge 1 commit into
opennextjs:mainfrom
andoan16:contribai/fix/security/hardcoded-s3-bucket-region-in-image-load
Open

fix(security): 2 improvements across 1 files#1176
andoan16 wants to merge 1 commit into
opennextjs:mainfrom
andoan16:contribai/fix/security/hardcoded-s3-bucket-region-in-image-load

Conversation

@andoan16

Copy link
Copy Markdown

Summary

fix(security): 2 improvements across 1 files

Problem

Severity: Medium | File: packages/open-next/src/overrides/imageLoader/s3.ts:L10

The S3 image loader has a hardcoded region 'us-east-1' which could lead to issues if the bucket is in a different region. This should be configurable via environment variables.

Solution

Replace the hardcoded region with an environment variable like process.env.S3_REGION || 'us-east-1'

Changes

  • packages/open-next/src/overrides/imageLoader/s3.ts (modified)

Testing

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

- Security: Hardcoded S3 Bucket Region in Image Loader
- Security: Missing Error Handling in S3 Image Loader

Signed-off-by: Ân Đoàn <33853760+andoan16@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented May 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5c33663

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

name: "s3",
load: async (key: string) => {
const s3Client = new S3Client({ logger: awsLogger });
const s3Client = new S3Client({ region: S3_REGION || 'us-east-1', logger: awsLogger });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is deployed on lambda, the region is set there. We should absolutely not set it to us-east-1

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.

2 participants