Skip to content

Commit c98377b

Browse files
fix(aws-serverless): Remove possible prototype pollution source (#14110)
Fixes [https://github.com/getsentry/sentry-javascript/security/code-scanning/307](https://github.com/getsentry/sentry-javascript/security/code-scanning/307) To fix the prototype pollution issue, we need to ensure that the `handlerName` does not include any special properties like `__proto__`, `constructor`, or `prototype`. We can achieve this by adding a check to filter out these properties before performing the assignment. 1. Add a check to ensure `handlerName` does not include `__proto__`, `constructor`, or `prototype`. 2. If `handlerName` includes any of these properties, log an error and return without making the assignment. _Suggested fixes powered by Copilot Autofix. Review carefully before merging._ Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent a091bdd commit c98377b

File tree

1 file changed

+6
-0
lines changed
  • packages/aws-serverless/src

1 file changed

+6
-0
lines changed

packages/aws-serverless/src/sdk.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ export function tryPatchHandler(taskRoot: string, handlerPath: string): void {
168168
return;
169169
}
170170

171+
// Check for prototype pollution
172+
if (functionName === '__proto__' || functionName === 'constructor' || functionName === 'prototype') {
173+
DEBUG_BUILD && logger.error(`Invalid handler name: ${functionName}`);
174+
return;
175+
}
176+
171177
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
172178
(mod as HandlerModule)[functionName!] = wrapHandler(obj);
173179
}

0 commit comments

Comments
 (0)