amplify-cli
amplify-cli copied to clipboard
fix(S3server): Uncontrolled data used in path expression
https://github.com/aws-amplify/amplify-cli/blob/3f255c91e15d52139ba001410929864982f433f0/packages/amplify-storage-simulator/src/server/S3server.ts#L130-L130
fix the issue need to ensure that the constructed filePath is validated to remain within the intended directory (this.localDirectoryPath). This can be achieved by:
- Normalizing the constructed path using
path.resolveto remove any..segments. - Verifying that the normalized path starts with the intended root directory (
this.localDirectoryPath). - If the path is outside the intended directory, return an appropriate error response (e.g., HTTP 403 Forbidden).
The changes will be made in the handleRequestGet method in packages/amplify-storage-simulator/src/server/S3server.ts.
Checklist
- [x] PR description included
- [x]
yarn testpasses - [x] Tests are changed or added
- [x] Relevant documentation is changed or added (and PR referenced)
- [x] New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
- [x] Pull request labels are added
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.