fix(security): replace in with Object.hasOwn in hasExplicitProviderAccountConfig#34995
fix(security): replace in with Object.hasOwn in hasExplicitProviderAccountConfig#34995manusjs wants to merge 1 commit intoopenclaw:mainfrom
in with Object.hasOwn in hasExplicitProviderAccountConfig#34995Conversation
…AccountConfig The `in` operator traverses the prototype chain, meaning a crafted accountId such as '__proto__', 'constructor', or 'toString' would erroneously return true — causing hasExplicitProviderAccountConfig to treat non-existent accounts as explicitly configured. Replace with Object.hasOwn() which only checks own enumerable properties, eliminating the prototype-pollution bypass. Fixes openclaw#34926
Greptile SummaryThis PR replaces the
Confidence Score: 5/5
Last reviewed commit: 4d7ba95 |
|
Hello @manusjs, thank you very much for your contribution. I really appreciate your work. Since we already have another pull request that was opened earlier (#34929) addressing this issue, I recommend commenting on the other pull request if you would like to suggest any changes. Thank you very much nevertheless. cc @shakkernerd, could you please close this so that we don’t run into confusion with multiple PRs? Thanks! |
What
Replace the
inoperator withObject.hasOwn()inhasExplicitProviderAccountConfigto prevent a prototype-pollution bypass.Why
The
inoperator checks the full prototype chain, not just own properties. An attacker who can influence theaccountIdvalue (e.g. via a specially crafted channel sender ID) could supply__proto__,constructor,toString, or any other inherited property name. The check would returntrue, causing the function to treat the account as explicitly configured — potentially suppressing security warnings or granting unintended access classifications.Fixes #34926
How
Object.hasOwn()only checks own enumerable properties (Node.js 16.9+, all modern environments). It is functionally equivalent to the old check for all legitimate account IDs and explicitly rejects prototype-chain properties.Testing
All 90 existing security audit tests pass:
Breaking Changes
None. All legitimate account IDs are own properties of the
accountsconfig object. The only behavioral change is that crafted prototype-property names no longer produce false positives.