npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hpp-guard

v1.0.0

Published

An Express middleware that enforces a global policy for HTTP Parameter Pollution (HPP).

Readme

hpp-guard (v1)

Web Security F25 – Final Project

Authors: Liz Grzyb, Mohamad Saaty, Ruohua Chen, Steven Chen

hpp-guard is a lightweight Express middleware that protects web applications from HTTP Parameter Pollution (HPP) attacks.
It supports both global duplicate-handling policies and per-parameter policies, allowing flexible and secure request validation.


Features

  • Global duplicate-handling policy

    • "reject" – block polluted requests
    • "first" – keep first value
    • "last" – keep last value
  • Per-parameter policies (paramModes)

    • Override the global mode for specific parameters
    • Example: "page": "first", "search": "last", "token": "reject"
  • Allowlist & multi-value exemptions

    • Only inspect certain parameters (allowlist)
    • Exempt parameters allowed to be arrays (multiValAllowed)
  • Body support

    • Validates query parameters
    • Optionally validates application/x-www-form-urlencoded bodies
  • Optional logging hook

    • onPollution(report, req) receives detailed pollution reports

Install

npm i hpp-guard

Basic Usage (Global)

This will block any request where a parameter appears more than once

const express = require("express");
const { hppGuard } = require("hpp-guard");

const app = express();

app.use(hppGuard({
  mode: "reject", // "reject" | "first" | "last"
}));

Per-Parameter Policies

Use paramModes to override the global mode for specific parameters.

app.use(hppGuard({
  mode: "reject",     // default for all parameters
  paramModes: {
    page: "first",    // keep the first ?page= value
    search: "last",   // keep the last ?search= value
    token: "reject",  // reject if duplicated
  }
}));

Allow List

Only inspect specific parameters:

app.use(hppGuard({
  allowlist: ["page", "search"]
}));

Multi-Value Allowed Parameters

Some parameters legitimagely appear more than once. multiValAllowed accomodates this.

app.use(hppGuard({
  multiValAllowed: ["tags"]
}));

Pollution Reporting

Provide a callback to inspect pollution events

app.use(hppGuard({
  onPollution: (report, req) => {
    console.log("HPP detected:", report);
  }
}));

Options Cheat Sheet

| Option | Type | Default | Description | | ----------------- | ----------- | ---------- | ---------------------------------------------------------- | | mode | string | "reject" | Global duplicate handling: "reject", "first", "last" | | paramModes | object/null | null | Per-parameter mode overrides | | allowlist | array/null | null | Only inspect these parameters | | multiValAllowed | array/null | null | Parameters allowed to be arrays | | checkBody | boolean | true | Whether to inspect urlencoded bodies | | onPollution | function | null | Callback for pollution events |