
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
hardened-https-agent
Advanced tools
A security-first https.Agent for Node.js that adds critical layers of trust to your HTTPS requests. Enforce modern security policies with support for Certificate Transparency, advanced revocation checks (CRLSet, OCSP), and custom CAs.
A security-first https.Agent for Node.js with advanced certificate validation: Custom CA, Certificate Transparency (CT), OCSP, and CRLSet.
A quick search on GitHub reveals a recurring pattern: developers are surprised to learn that Node.js does not validate TLS certificates the same way a browser does. Issues have been raised in popular projects like got and Uptime Kuma when users discover that connections to servers with revoked certificates succeed without any warning.
This behavior is, in fact, (more or less) intentional. As explained in the Node.js repository itself (#16338), performing robust, browser-grade checks for things like certificate revocation is a complex task with performance and privacy trade-offs. Node.js provides the necessary cryptographic building blocks, but leaves the responsibility of implementing these advanced security policies entirely up to the developer.
This is where hardened-https-agent comes in. It provides modern, browser-grade security policies for your outbound TLS connections in two powerful ways:
HardenedHttpsAgent that acts as a secure, drop-in replacement for Node.js's default agent.HardenedHttpsValidationKit that exports the core validation logic, allowing you to secure other HTTPS agents (like proxy-agents) or raw tls.TLSSocket directly.It works with any library supporting the standard https.Agent, including axios, got, node-fetch, needle, and more.
hardened-https-agent| Verification Check | Default Node.js (https.Agent) | hardened-https-agent |
|---|---|---|
| Trust Model | ||
| Custom CA Store | ⚠️ (Optional ca prop.) | ✅ (Enforced, with helpers) |
| Certificate Revocation | ||
| OCSP Stapling | ⚠️ (Raw staple, not validated) | ✅ |
| OCSP Direct | ❌ | ✅ |
| CRLs | ⚠️ (Manual CRL file only) | ⏳ (Planned) |
| CRLSet | ❌ | ✅ |
| CRLite | ❌ | ⏳ (Planned) |
| Certificate Integrity | ||
| Certificate Transparency (CT) | ❌ | ✅ |
See BACKGROUND.md: Why a Hardened Agent? for a detailed technical explanation of the gaps in Node.js's default behavior.
This library is designed for any Node.js application that needs to reliably verify the authenticity of a remote server. Its primary goal is to protect against connecting to servers using revoked or mis-issued certificates, a check that Node.js does not perform by default.
It's essential for:
axios or got.https-proxy-agent.tls.TLSSocket instances.The library ships with a set of pre-defined policies for common needs, while also providing complete control to create a tailored policy that fits your exact security requirements.
npm install hardened-https-agent
This library can be used in two primary ways: as a simple, all-in-one agent, or as a standalone validation kit for advanced use cases.
HardenedHttpsAgent (Simple)This is the easiest way to get started. The HardenedHttpsAgent is a drop-in replacement for the default https.Agent and handles all validation internally.
By simply using this setup, you immediately benefit from all the built-in security layers: CA validation using the Cloudflare bundle, certificate revocation checks via OCSP (stapling and direct), CRLSet-based revocation with signature verification (using the latest Google CRLSet), and enforcement that the presented certificate is properly published in Certificate Transparency logs. All of this is enabled out of the box, no extra configuration required.
import { HardenedHttpsAgent, defaultAgentOptions } from 'hardened-https-agent';
// Customize standard agent options if required
const httpsAgentOptions: https.AgentOptions = {
keepAlive: true,
timeout: 55000,
maxSockets: 20,
maxFreeSockets: 5,
maxCachedSessions: 500,
};
// Merge standard agent options with hardened defaults
const agent = new HardenedHttpsAgent({
...httpsAgentOptions,
...defaultAgentOptions(),
});
const client = axios.create({ httpsAgent: agent, timeout: 15000 });
const response = await client.get('https://example.com');
// You've got your first hardened `response`
Real-world examples (for axios, got, node:https, custom policies, and more) are available in the examples directory.
If your preferred HTTP client is missing, feel free to open an issue to request an example or confirm compatibility.
HardenedHttpsValidationKit (Advanced)For more complex scenarios, the core validation logic is exported as the HardenedHttpsValidationKit. This is useful when you can't simply replace the https.Agent, since Node.js does not provide a straightforward way to "compose" or "wrap" agents.
Using the validation kit is a two-step process:
kit.applyBeforeConnect(options). This function returns a modified options object, allowing the kit's validators to inject any necessary parameters (e.g., forcing requestOCSP: true for OCSP stapling) before a connection is attempted.http.Agent instance or a raw tls.TLSSocket.
kit.attachToAgent(agent) (High-Level): This is the easiest method. It hooks into the agent's keylog event to automatically validate the underlying socket.kit.attachToSocket(socket) (Low-Level): This gives you fine-grained control, attaching the validation logic directly to a socket you manage.Here is an example of how to enhance https-proxy-agent:
import { HttpsProxyAgent, HttpsProxyAgentOptions } from 'https-proxy-agent';
import { HardenedHttpsValidationKit, defaultAgentOptions } from 'hardened-https-agent';
// Create a validation kit with hardened defaults
const kit = new HardenedHttpsValidationKit({
...defaultAgentOptions(),
});
// Define your HTTPS proxy agent options as usual
const httpsProxyAgentOpts: HttpsProxyAgentOptions<'https'> = {
keepAlive: true,
};
// Create the proxy agent, applying validation kit to options before passing them
const agent = new HttpsProxyAgent('http://127.0.0.1:3128', kit.applyBeforeConnect(httpsProxyAgentOpts));
// Attach the validation kit to the agent
kit.attachToAgent(agent as http.Agent);
const req = https.request(
'https://example.com',
{ method: 'GET', agent: agent as http.Agent, timeout: 15000 },
(response) => {
// You've got your first hardened `response`
},
);
A complete example is available at examples/validation-kit.ts.
tls.TLSSocketFor maximum control, you can apply validation directly to a tls.TLSSocket. This is the same method the HardenedHttpsAgent uses internally. You can view its source code in src/agent.ts for a real-world implementation.
The process involves calling tls.connect with the modified options and then immediately attaching the kit to the newly created socket. After attaching, the socket will emit a custom hardened:validation:success event; once this fires, the socket is safe to use (e.g., in createConnection flows or other custom integrations). If validation fails, the socket emits hardened:validation:error and is forcibly destroyed to prevent use, so you can simply handle the failure via the standard error event as well.
// Assume `kit` is an initialized HardenedHttpsValidationKit
// and `options` are your initial tls.connect options.
// Allow validators to modify the connection options
const finalOptions = this.#kit.applyBeforeConnect(options);
// Create the socket
const tlsSocket = tls.connect(finalOptions);
// Handle validation success
tlsSocket.on('hardened:validation:success', () => {
this.#logger?.info('TLS connection established and validated.');
callback(null, tlsSocket);
});
// Handle socket errors
tlsSocket.on('error', (err: Error) => {
this.#logger?.error('An error occurred during TLS connection setup', err);
callback(err, undefined as any);
});
// Attach the validation kit to the socket
this.#kit.attachToSocket(tlsSocket);
HardenedHttpsAgent & HardenedHttpsValidationKit OptionsThe options below are used to configure the security policies of the HardenedHttpsAgent. When using the HardenedHttpsValidationKit, only a subset of these options are available (ctPolicy, ocspPolicy, crlSetPolicy, and loggerOptions).
| Property | Type | Required / Variants | Helper(s) |
|---|---|---|---|
ca | string | Buffer | Array<string | Buffer> | Required. Custom trust store that replaces Node.js defaults. Accepts PEM string, Buffer, or an array of either. | embeddedCfsslCaBundle, useNodeDefaultCaBundle() |
ctPolicy | CertificateTransparencyPolicy | Optional. Enables CT when present. Fields: logList: UnifiedCTLogList, minEmbeddedScts?: number, minDistinctOperators?: number. | basicCtPolicy(), embeddedUnifiedCtLogList |
ocspPolicy | OCSPPolicy | Optional. Enables OCSP when present. Fields: mode: 'mixed' | 'stapling' | 'direct', failHard: boolean. | basicStaplingOcspPolicy(), basicDirectOcspPolicy() |
crlSetPolicy | CRLSetPolicy | Optional. Enables CRLSet when present. Fields: crlSet?: CRLSet, verifySignature?: boolean, updateStrategy?: 'always' | 'on-expiry'. | basicCrlSetPolicy() |
loggerOptions | LoggerOptions | Optional. Logging configuration (level, sink, formatter, template). | defaultLoggerOptions() |
| Standard HTTPS opts | https.AgentOptions | Optional. Any standard Node.js https.Agent options (e.g., keepAlive, maxSockets, timeout, maxFreeSockets, maxCachedSessions) can be merged alongside the hardened options. |
All options are thoroughly documented directly in the library via JSDoc comments for easy in-editor reference and autocomplete.
Import convenience presets and building blocks as needed, to help you construct your custom HardenedHttpsAgent:
import {
defaultAgentOptions,
useNodeDefaultCaBundle,
embeddedCfsslCaBundle,
embeddedUnifiedCtLogList,
basicCtPolicy,
basicMixedOcspPolicy,
basicStaplingOcspPolicy,
basicDirectOcspPolicy,
basicCrlSetPolicy,
} from 'hardened-https-agent';
The default helpers such as embeddedCfsslCaBundle and embeddedUnifiedCtLogList use embedded resources committed in this repository (CA bundle from Cloudflare CFSSL; unified CT log list merged from Google and Apple sources).
useNodeDefaultCaBundle() if that trust model better suits your environment.HardenedHttpsAgent customization (quick recipes)Bring your own CA bundle:
new HardenedHttpsAgent({ ...defaultAgentOptions(), ca: myPemStringOrBuffer });
Use Node default CA bundle:
new HardenedHttpsAgent({ ...defaultAgentOptions(), ca: useNodeDefaultCaBundle() });
Tune standard https.Agent behavior:
new HardenedHttpsAgent({
...defaultAgentOptions(),
keepAlive: true,
maxSockets: 50,
});
Use a custom CT policy:
new HardenedHttpsAgent({
...defaultAgentOptions(),
ctPolicy: {
logList: embeddedUnifiedCtLogList,
minEmbeddedScts: 3,
minDistinctOperators: 3,
},
});
Use a custom OCSP policy:
new HardenedHttpsAgent({
...defaultAgentOptions(),
ocspPolicy: {
mode: 'stapling',
failHard: true,
},
});
Use a custom CRLSet policy:
new HardenedHttpsAgent({
...defaultAgentOptions(),
crlSetPolicy: {
verifySignature: true,
updateStrategy: 'always',
},
});
Enable detailed logs:
new HardenedHttpsAgent({ ...defaultAgentOptions(), loggerOptions: { level: 'debug' } });
We welcome contributions of all kinds! A great place to start is by checking out the Roadmap for planned features or looking at the open issues for bugs and feature requests.
Before you get started, please take a moment to review our CONTRIBUTING.md guide, which contains all the information you need to set up your environment and submit your changes.
hardened-https-agent is distributed under the MIT license.
FAQs
A security-first https.Agent for Node.js that adds critical layers of trust to your HTTPS requests. Enforce modern security policies with support for Certificate Transparency, advanced revocation checks (CRLSet, OCSP), and custom CAs.
The npm package hardened-https-agent receives a total of 0 weekly downloads. As such, hardened-https-agent popularity was classified as not popular.
We found that hardened-https-agent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.