Skip to content

Commit 4a1310d

Browse files
committed
Fixed prototype pollution when using dataType: 'json'
1 parent 58faeb9 commit 4a1310d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Headlines: Added, Changed, Deprecated, Removed, Fixed, Security
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [2.27.3] - 2025-10-14
8+
## [2.27.4] - 2025-10-14
99

1010
### Security
1111

src/lib/traversal.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export function traversePath<T extends object>(
5252
modifier?: (data: PathData) => undefined | unknown | void
5353
): PathData | undefined {
5454
if (!realPath.length) return undefined;
55+
56+
// Prevent prototype injection
57+
if (realPath.includes('__proto__') || realPath.includes('prototype')) {
58+
throw new Error("Cannot set an object's `__proto__` or `prototype` property");
59+
}
60+
5561
const path = [realPath[0]];
5662

5763
let parent = obj;

0 commit comments

Comments
 (0)