Skip to content

Commit c9edba3

Browse files
committed
Docs: strengthen Snippets warning and add security considerations
Provided by @0xmrma
1 parent 6d92b68 commit c9edba3

2 files changed

Lines changed: 47 additions & 4 deletions

File tree

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
*[Toc]: Table of Contents
2-
*[GFM]: GitHub Flavored Markdown
31
*[FAQ]: Frequent Asked Questions
2+
*[GFM]: GitHub Flavored Markdown
3+
*[SSRF]: Server-Side Request Forgery
4+
*[Toc]: Table of Contents

docs/src/markdown/extensions/snippets.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ icon: lucide/square-scissors
88
## Overview
99

1010
/// warning | Not Meant for User Facing Sites
11-
Snippets is meant to make including snippets in documentation easier, but it should not be used for user facing sites
12-
that take and parse user content dynamically.
11+
Snippets is intended for documentation/static content workflows and **must not** be used to render untrusted/user-supplied
12+
content dynamically (public-facing sites, user comments, wikis, etc.).
13+
14+
**Security note:** enabling features like **URL Snippets** (`url_download`) can cause the renderer to make outbound HTTP
15+
requests to arbitrary URLs (including localhost/internal networks), which can lead to SSRF-style risk in unsafe
16+
deployments.
17+
18+
See [Security Considerations](#security-considerations) for details and concrete examples.
1319
///
1420

1521
Snippets is an extension to insert markdown or HTML snippets into another markdown file. Snippets is great for
@@ -293,6 +299,42 @@ is especially useful for including a page of reference links or abbreviations on
293299
Snippets provides an `auto_append` option that allows a user to specify a list of files that will be automatically
294300
appended to every Markdown content. Each entry in the list is searched for relative to the `base_path` entries.
295301

302+
## Security Considerations
303+
304+
Snippets is designed for documentation workflows and static content generation. It is **not** intended for use in
305+
public-facing services that render untrusted/user-supplied Markdown dynamically.
306+
307+
### Why This Matters
308+
309+
When Snippets processes a directive as shown below, it will attempt to include the referenced content into the rendered
310+
output.
311+
312+
```text
313+
---8<--- "some-target"
314+
```
315+
316+
If **URL Snippets** are enabled via `url_download`, the renderer may download content from arbitrary URLs. In unsafe
317+
deployments, this can cause the rendering environment to make outbound HTTP requests to attacker-chosen locations
318+
(including localhost and internal networks), which can resemble SSRF-style behavior.
319+
320+
### Unsafe Example (Do Not Use With Untrusted Input)
321+
322+
If an attacker can influence Markdown content and `url_download` is enabled, they may be able to trigger requests such
323+
as:
324+
325+
```text
326+
---8<--- "http://127.0.0.1:9999/"
327+
```
328+
329+
### Safe Usage Guidance
330+
331+
If you use Snippets in public-facing CI, preview builds, or documentation pipelines:
332+
333+
- Treat untrusted contributions with caution (e.g., PRs from external contributors).
334+
- Run builds in a sandbox/container with restrictive network/egress policies.
335+
- Avoid enabling `url_download` unless you fully understand the risk and have appropriate isolation in place.
336+
- Prefer static, trusted snippet sources whenever possible.
337+
296338
## Options
297339

298340
Option | Type | Default | Description

0 commit comments

Comments
 (0)