Documentation
¶
Overview ¶
Package prototype implements Prototype Pollution detection.
Source reference: PPmap (MIT, kleiton0x00) + prototype-pollution-checker (MIT) + PortSwigger prototype pollution research. Detection logic reimplemented from scratch.
Prototype Pollution occurs when user-controlled input is used to modify JavaScript's Object.prototype, affecting all objects in the application.
This module detects server-side prototype pollution (SSPP) via:
- JSON body injection: inject {"__proto__":{"canary":"BHJSPP_<random>"}} or {"constructor":{"prototype":{"canary":"..."}}} in POST/PUT requests
- Query param injection: ?__proto__[canary]=BHJSPP_xxx or ?constructor[prototype][canary]=BHJSPP_xxx
- Response verification: if canary appears in response → SSPP confirmed
- HTTP header reflection: inject via arbitrary header values
Client-side prototype pollution (CSPP) detection via DOM clobbering signals:
- Check if response body references globals that could be polluted
- Check for dangerous eval() or Function() patterns with user-controlled data
Architecture:
- Probe struct: ID, Location, Inject (template with {CANARY}), Detect func
- errgroup.SetLimit(Parallelism) fan-out
- io.LimitReader on all reads
- log/slog observability
- sync.Mutex protecting findings
- NewWithClient(*http.Client) + NewWithProbes([]Probe) for testability
Index ¶
Constants ¶
const ( DefaultTimeout = 10 * time.Second DefaultParallelism = 10 // LocationQuery injects into query parameters. LocationQuery = "query" // LocationJSON injects into JSON POST body. LocationJSON = "json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements Prototype Pollution detection.
func NewWithClient ¶
NewWithClient returns a Module using the supplied HTTP client.
func NewWithProbes ¶
NewWithProbes returns a Module with custom probes (testability).
func NewWithProbesAndClient ¶
NewWithProbesAndClient returns a Module with custom probes and HTTP client.
type Probe ¶
type Probe struct {
// ID is a unique slug.
ID string
// Location is where the payload is injected (LocationQuery or LocationJSON).
Location string
// InjectTemplate is the injection pattern. {CANARY} is replaced with the unique canary.
// For JSON: the full JSON body template.
// For query: the parameter format "param=value".
InjectTemplate string
// Severity of the finding.
Severity module.Severity
// Tags are metadata tags.
Tags []string
}
Probe defines a prototype pollution test.