Skip to content

Disable file includes in Org and AsciiDoc rendering - #13

Merged
andrew merged 1 commit into
mainfrom
disable-file-includes
Nov 23, 2026
Merged

andrew merged 1 commit into
mainfrom
disable-file-includes

Conversation

@andrew

@andrew andrew commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Rendering untrusted Org or AsciiDoc content could inline any file the process can read. #+INCLUDE: "/etc/passwd" src text in a .org file went through go-org's default ReadFile, and include::/etc/passwd[] in a .adoc file was expanded because asciidoctor runs in unsafe mode by default from the CLI.

OrgRenderer now sets ReadFile to a function that always returns an error, which covers both #+INCLUDE and #+SETUPFILE. The AsciiDoc renderer passes --safe-mode secure, so an include directive renders as a link to the path and the file is never read.

reStructuredText already ran with --no-file-insertion and is unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • AsciiDoc and Org documents can no longer expose local file contents through file includes during rendering.
    • AsciiDoc rendering now runs in secure mode, and Org rendering blocks file reads.
    • Added coverage for absolute and relative include paths, including includes inside AsciiDoc source blocks. Tests confirm that temporary file contents are absent from rendered output.

go-org's default ReadFile and asciidoctor's default unsafe mode let
#+INCLUDE and include:: inline any file the process can read.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7c108722-6418-48eb-bd8a-2f0917d8b1f2
Commits

Reviewing files that changed from the base of the PR and between a34c9d5 and a34c9d5.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The Org parser now rejects file reads, and the default AsciiDoc renderer uses secure mode. New tests check that absolute and relative include directives do not expose temporary file contents in rendered output.

Changes: Renderer file access restrictions

Layer / File(s) Summary
Restrict renderer file access
org.go, markup.go, markup_test.go
The Org parser rejects file reads, and the default AsciiDoc renderer uses --safe-mode secure. Tests check that absolute and relative include paths do not expose temporary file contents. The AsciiDoc test skips when its renderer is unavailable.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to a34c9

This change stops Org and AsciiDoc rendering from reading files from disk through include directives. It adds tests for the include paths. No remaining merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Disable file includes in Org and AsciiDoc rendering" matches the main change. The org.go change makes go-org's ReadFile callback return an error, and markup.go passes --safe-mode secure to …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Disable file includes in Org and AsciiDoc rendering" matches the main change. The org.go change makes go-org's ReadFile callback return an error, and markup.go passes --safe-mode secure to asciidoctor, so both renderers stop inlining files. The title is specific, concise, and matches the PR objective.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 41f70bd7-de95-41ce-b35a-d8fe7ed1ac5b
Commits

Reviewing files that changed from the base of the PR and between 0cf03b6 and a34c9d5.

Files selected for processing: 3

  • markup.go
  • markup_test.go
  • org.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@andrew
andrew added this pull request to stack #16 November 23, 2026 08:42
@andrew
andrew merged commit 28fe1b6 into main Nov 23, 2026
6 checks passed
@andrew
andrew deleted the disable-file-includes branch November 23, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant