Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Prototype Pollution in `hapi-error`

Open
#86 2 comments 1 reaction 0 assignees View on GitHub

@gnsehfvlr is already working on this.

Since Mar 30, 2026.

  • #87 by @gnsehfvlr — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
security

Research direction

Start at the plugin.register entry point and reproduce the three reported attack vectors from the proof of concept. Check that user-controlled keys cannot alter Object.prototype, then verify the demonstrated pollution checks no longer succeed and add coverage for the reported cases.

Written by the indexing model from the issue text.

Description

Prototype Pollution in hapi-error

Summary

hapi-error (<= 3.0.0) is vulnerable to Prototype Pollution via plugin.register.

Description

The function(s) plugin.register in hapi-error do not properly restrict modifications to Object.prototype. When processing user-controlled input, an attacker can inject properties via __proto__ or constructor.prototype keys, polluting the prototype of all JavaScript objects in the application.

Attack vectors: __proto__ direct, __proto__ nested, constructor.prototype

Proof of Concept

const target = require('hapi-error');

// 1. Pollute Object.prototype
const malicious = JSON.parse('{"__proto__":{"polluted":"yes"}}');
hapi-error.plugin.register({}, malicious);

// 2. Verify pollution
const obj = {};
console.log(obj.polluted); // "yes" - prototype is polluted
console.log('Vulnerable:', obj.polluted === 'yes');

Impact

Successful exploitation allows an attacker to:

  • Denial of Service (DoS) by overriding critical object methods like toString or hasOwnProperty
  • Authentication Bypass via polluted authorization checks
  • Remote Code Execution (RCE) when combined with gadgets (e.g., child_process.spawn with shell:true pollution)

Remediation

Add key filtering to prevent prototype pollution:

function isSafe(key) {
  return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
}

Or use Object.create(null) for target objects to prevent prototype chain access.

References

Dominant language
JavaScript
Stars
76
Forks
12
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dwyl/hapi-error

All issues in dwyl/hapi-error

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.