Skip to main content
Version: v0.35.0

Security Considerations

If you're going to give app access to untrusted users, there's some security considerations that you'll need to be aware of given how the crawler works. The crawler is basically running a browser to fetch the content of the bookmarks. Any untrusted user can submit bookmarks to be crawled from your server and they'll be able to see the crawling result. This can be abused in multiple ways:

  1. Untrusted users can submit crawl requests to websites that you don't want to be coming out of your IPs.
  2. Crawling user controlled websites can expose your origin IP (and location) even if your service is hosted behind cloudflare for example.
  3. The crawling requests will be coming out from your own network, which untrusted users can leverage to crawl internal non-internet exposed endpoints.

To mitigate those risks, you can do one of the following:

  1. Limit access to trusted users
  2. Let the browser traffic go through some VPN with restricted network policies.
  3. Host the browser container outside of your network.
  4. Use a hosted browser as a service (e.g. browserless). Note: I've never used them before.

Server-Side Request Forgery (SSRF) protections​

Karakeep has basic Server-Side Request Forgery (SSRF) protections to avoid probing internal endpoints. Before the workers fetch a URL, Karakeep resolves its hostname and blocks the request if it resolves to a private, loopback, link-local or other internal address (unless the hostname is allowlisted with CRAWLER_ALLOWED_INTERNAL_HOSTNAMES). The connection is then pinned to the validated addresses, so the hostname can't be re-resolved to a different address in between.

These checks only cover the requests made by the workers' own process. Three components make their own network requests outside of that protection:

  • The headless browser. Karakeep validates the page URL, its redirects and the sub-resource requests (scripts, images, iframes, …) the browser makes, but Chromium resolves DNS on its own. A hostname that resolves to a public address when Karakeep checks it and to an internal one when Chromium connects (DNS rebinding) passes the check, for both the page and its sub-resources. WebSocket connections that pages open aren't validated at all.
  • The full-page archiver (monolith). When Karakeep creates a full-page archive, monolith fetches the page's sub-resources again itself, without any validation, and their contents end up in the archive that users can download. Setting CRAWLER_FULL_PAGE_ARCHIVE=false only disables automatic archiving: users can still request an archive of individual bookmarks.
  • Video downloads (yt-dlp). When video downloads are enabled (CRAWLER_VIDEO_DOWNLOAD or CRAWLER_VIDEO_DOWNLOAD_ON_DEMAND), yt-dlp makes its own requests and follows redirects without validation.

If untrusted users can access your instance, don't rely on these checks alone. Instead, route the crawler's traffic through an egress proxy or a network policy that blocks internal, private, link-local and cloud metadata (e.g. 169.254.169.254) addresses:

  • Set CRAWLER_HTTP_PROXY and CRAWLER_HTTPS_PROXY (see the configuration docs) to a proxy running outside of your internal network, or one that refuses internal destinations. The browser (including its WebSocket connections), monolith and yt-dlp all use it. Since the proxy resolves DNS, Karakeep skips its own internal address checks for proxied requests, so the proxy itself has to block internal destinations. Hosts listed in CRAWLER_NO_PROXY bypass the proxy for all traffic. Their HTTP(S) requests still get Karakeep's own checks, but WebSocket connections to them aren't checked at all, so keep that list short and leave out loopback addresses (e.g. localhost, 127.0.0.1) on instances with untrusted users.
  • Alternatively, run the browser and the workers on a network that can't reach your internal services.
  • If you don't need video downloads, disable them with CRAWLER_VIDEO_DOWNLOAD=false and CRAWLER_VIDEO_DOWNLOAD_ON_DEMAND=false.