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

@terraza/safe-fetch

v0.1.0

Published

SSRF-safe HTTP(S) fetch for Terraza: manual redirect handling, per-hop host validation, and DNS-pinned connections that reject private/loopback/link-local targets

Readme

@terraza/safe-fetch

SSRF-safe HTTP(S) fetch for Terraza. Zero runtime dependencies (Node core only).

The platform kept hitting the same bug: validate the initial URL's host, then fetch(..., { redirect: "follow" }) — which chases 3xx redirects and independently re-resolves DNS, so a redirect to an internal host or a low-TTL DNS rebind (TOCTOU) reaches a target the check was meant to block. The 2026-07-03 fleet audit found it in four places. This package is the single fix; route every "fetch a URL that could be attacker-influenced" call through it.

Guarantees

  • Manual redirects, re-validated per hop — no redirect: "follow".
  • DNS-pinned connections — each request resolves once, validates every returned address, and pins the vetted IP into the socket, so the connection lands on exactly the address checked. Closes the rebind TOCTOU.
  • Blocks internal targets — loopback, RFC1918 private, link-local (incl. cloud metadata 169.254.169.254), CGNAT, IPv6 ULA/link-local, multicast, and v4-mapped v6. Unparseable addresses fail closed.
  • TLS unchanged — SNI and cert validation stay bound to the real hostname; only the connect-time IP is pinned.
  • Bounded — body-size cap and an overall timeout across all hops.

Usage

import { safeFetch, SsrfError } from "@terraza/safe-fetch";

const res = await safeFetch(url, {
  maxBytes: 64 * 1024,
  timeoutMs: 5_000,
  maxRedirects: 0, // reject any redirect (e.g. static docs that must be same-origin)
});
if (!res.ok) throw new Error(`fetch failed: ${res.status}`);
const doc = res.json();

safeFetch throws SsrfError when a target resolves to a private/internal address or a non-http(s) scheme, and SafeFetchError on timeout, size-cap, or redirect-limit.

Also exported: assertPublicHost(hostname) (resolve + validate without fetching) and the isPrivateAddress(ip) / isPrivateIpv4(ip) classifiers.

Consumers

Adopted by (or slated for): @terraza/terraza-mcp CIMD fetch, terraza-shelf url-ingest, terraza-post attachment fetch. See terraza/platform/references/security-audit-2026-07-03.md.

The isAddressBlocked / resolveHost options are dependency-injection seams for tests and advanced callers; overriding isAddressBlocked disables the SSRF guard, so never wire it to untrusted input.