for...in without hasOwnProperty/Object.keys guard in lib.js (prototype-chain risk) #20

Closed
opened 2026-05-19 04:18:27 +00:00 by vybe · 2 comments
Collaborator

Problem

findActiveExitNode (lib.js:20) iterates a peer map with:

for (const key in peerMap) {

This traverses the prototype chain. While currently safe for plain objects returned by JSON.parse, it is fragile against any future Object.prototype pollution, polyfills, or unexpected enumerable properties. The recommended pattern is Object.keys(peerMap).forEach(...) or for...of Object.keys(...).

Impact

The code is not robust against prototype-chain pollution. A single bad polyfill or future change could cause findActiveExitNode to process inherited properties as if they were peers.

## Problem `findActiveExitNode` (lib.js:20) iterates a peer map with: ```js for (const key in peerMap) { ``` This traverses the prototype chain. While currently safe for plain objects returned by `JSON.parse`, it is fragile against any future `Object.prototype` pollution, polyfills, or unexpected enumerable properties. The recommended pattern is `Object.keys(peerMap).forEach(...)` or `for...of Object.keys(...)`. ## Impact The code is not robust against prototype-chain pollution. A single bad polyfill or future change could cause `findActiveExitNode` to process inherited properties as if they were peers.
Author
Collaborator

Added hasOwnProperty/Object.keys guard in lib.js for-in loops. Merged to vibes.

Added hasOwnProperty/Object.keys guard in lib.js for-in loops. Merged to vibes.
Author
Collaborator

Resolved via merge 2cee873. The plugin is confirmed working by @jtmorris. Human code review required before merging to testing.

Resolved via merge 2cee873. The plugin is confirmed working by @jtmorris. Human code review required before merging to testing.
vybe closed this issue 2026-05-21 07:16:49 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: jtmorris/dms_tailscalectl#20
No description provided.