


























Can’t get enough of SSRF vulnerabilities, can we now? In this vulnerable npm package we analyze a vulnerability within safe-axios, an open-source npm package designed to safeguard applications from SSRF (Server-Side Request Forgery) attacks. While safe-axios attempts to validate URLs via a denylist, an outdated list creates a bypass window for malicious actors. Let’s explore the technical nitty-gritty and understand the potential consequences.
SSRF vulnerabilities emerge when an application unintentionally makes requests to external servers based on user-controlled input. Attackers can exploit this to fetch internal resources, execute unauthorized actions, or even launch denial-of-service attacks.
safe-axios aims to mitigate this risk by offering URL validation. It maintains a static denylist of IP addresses and ranges considered risky for outbound requests. If a URL resolves to an IP on this list, the request gets flagged as potentially malicious.
However, a closer look reveals a critical flaw in safe-axios’s defense mechanism.
The crux of the issue lies in safe-axios’s denylist. This list, meant to identify unsafe IP addresses, is outdated or incomplete. As a result, it overlooks crucial reserved IP address spaces as defined by the IANA (Internet Assigned Numbers Authority).
Specifically, the denylist misses the following reserved ranges:
192.31.196.0/24
192.52.193.0/24
192.175.48.0/24
These ranges are typically used for multicast traffic and other special purposes within local networks. While exploiting them for SSRF attacks might be less common, it highlights a vulnerability in safe-axios’s logic.
For a more robust safety net, SSRF protection libraries should adhere to established standards for identifying invalid public IP addresses. Notably, popular npm packages like ipaddr.js correctly classify these ranges as reserved.
To illustrate the bypass, let’s consider the following proof of concept example and SSRF reproducible scenario:
safe-axios package:app.js file with the programmatic API of safe-axios:import SafeAxios from 'safe-axios';
async function main() {
const safeAxios = SafeAxios.default;
// this request is allowed by safe axios even though it is in a reserved IP address space
const data = await safeAxios.request({url: 'https://192.32.196.4/test'});
}
main();
As you can see, safe-axios incorrectly validates a URL with a reserved IP address, potentially allowing an attacker to exploit this vulnerability.
🔥 New: Bun Security Essentials on a limited time offer for the course & book teaching you Bun security practices Bun Security Essentials
I disclosed this vulnerability to the safe-axios maintainers via a GitHub issue, and detailed this headers redirect bypass in a full security vulnerability disclosure report.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。