Skip to content

Security: Prototype Pollution via Custom Attributes in BearerTokenType#440

Open
tomaioo wants to merge 1 commit into
node-oauth:masterfrom
tomaioo:fix/security/prototype-pollution-via-custom-attribute
Open

Security: Prototype Pollution via Custom Attributes in BearerTokenType#440
tomaioo wants to merge 1 commit into
node-oauth:masterfrom
tomaioo:fix/security/prototype-pollution-via-custom-attribute

Conversation

@tomaioo

@tomaioo tomaioo commented Jun 15, 2026

Copy link
Copy Markdown

Summary

Security: Prototype Pollution via Custom Attributes in BearerTokenType

Problem

Severity: Medium | File: lib/token-types/bearer-token-type.js:L58

In BearerTokenType.valueOf(), custom attributes are iterated using for...in without proper prototype chain protection. While Object.prototype.hasOwnProperty.call is used, if customAttributes itself is an object with a polluted prototype (e.g., via __proto__ or constructor), properties from the prototype chain could be included in the token response. Additionally, the constructor allows customAttributes to be any object, which could lead to information disclosure or unexpected behavior if malicious properties are passed.

Solution

Use Object.keys(this.customAttributes) instead of for...in to avoid prototype chain iteration, or ensure customAttributes is created with Object.create(null). Also validate that customAttributes only contains expected types (strings, numbers, booleans) to prevent object injection attacks.

Changes

  • lib/token-types/bearer-token-type.js (modified)

In `BearerTokenType.valueOf()`, custom attributes are iterated using `for...in` without proper prototype chain protection. While `Object.prototype.hasOwnProperty.call` is used, if `customAttributes` itself is an object with a polluted prototype (e.g., via `__proto__` or `constructor`), properties from the prototype chain could be included in the token response. Additionally, the constructor allows `customAttributes` to be any object, which could lead to information disclosure or unexpected behavior if malicious properties are passed.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@jankapunkt

Copy link
Copy Markdown
Member

Dear @tomaioo if you think this is related to a reproducible vulnerability then please open a new advisory: https://github.com/node-oauth/node-oauth2-server/security/advisories/new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants