# GHSA-XRC8-GJ3Q-M8VM: Legacy pdf\_compare tool bypasses the --allow-dir / MCP\_PDF\_ALLOWED\_DIRS filesystem allowlist

- Database: GitHub
- Severity: CVSS 4.3 (Medium)
- Published: 2026-10-19
- Modified: 2026-10-19

## Affected versions

- @sylphx/anymd (npm): from 7.0.0, through 8.5.4
- @sylphx/citra (npm): from 5.0.4, through 8.5.4
- @sylphx/pdf-reader-mcp (npm): from 7.0.0, through 8.5.4

## Description

## Summary
Every PDF tool in the Rust server confines file paths to the directories configured with `--allow-dir` / `MCP_PDF_ALLOWED_DIRS` (the control added for GHSA-qr3f-g5wf-225w): `read_pdf`, `search_pdf`, `pdf_evidence` and `inspect{compare}` all call `source_access.admit_*` before opening a file. The legacy `pdf_compare` tool does not. It passes the caller's `before` / `after` paths straight to the comparison engine, so a client (or a prompt-injected agent) can make the server open PDFs outside the allowlist and return their extracted terms, page counts and character counts. It also acts as an existence oracle for arbitrary paths. Confirmed on 8.5.4 (latest).

## Details
`crates/anymd/src/lib.rs`:

- `call_tool` → `call_legacy` → `"pdf_compare"` → `PdfReaderMcp::pdf_compare()` (around line 306).
- `pdf_compare()` runs `args.validate()` and then serializes the args directly into `pdf_compare::pdf_compare(value)`. There is no `source_access.admit_path(...)` call.
- `anymd-core/src/compare_pdf.rs` then does `extract_page_texts(PathBuf::from(&input.before))` / `(&input.after)` on the raw caller strings.

Compare with the sibling entrypoints in the same file, which admit every path first: `read_pdf` (~277), `search_pdf` (~325), `pdf_evidence` (~363) and `inspect{compare}` (~458-462). `inspect{compare}` performs the same comparison through the guarded path, so only the legacy entrypoint is missing the check. `pdf_compare` was added after the allowlist landed (#727, after 5.0.2), which looks like a sibling missed by the GHSA-qr3f fix. It is unlisted in `tools/list` since 7.0.0 but still callable through `tools/call`.

The response includes up to 200 `added_terms` and 200 `removed_terms` (sorted unique terms, so digits such as amounts, dates and IDs come first), plus `before_pages`, `after_pages`, `changed_pages`, `before_chars` and `after_chars`. Error messages also reveal whether a path exists and is a readable PDF.

**Suggested fix** (validated): admit both paths, mirroring `inspect{compare}`.

```diff
     pub async fn pdf_compare(
         &self,
-        Parameters(args): Parameters<ComparePdfArgs>,
+        Parameters(mut args): Parameters<ComparePdfArgs>,
     ) -> Result<rmcp::model::CallToolResult, ErrorData> {
         args.validate()
             .map_err(|message| ErrorData::invalid_params(message, None))?;
+        args.before = self
+            .source_access
+            .admit_path(&args.before)
+            .map_err(|message| ErrorData::invalid_params(message, None))?;
+        args.after = self
+            .source_access
+            .admit_path(&args.after)
+            .map_err(|message| ErrorData::invalid_params(message, None))?;
         let value = serde_json::to_value(args).map_err(|error| {
```

With this patch the PoC below is denied with "Access denied", and the existing `anymd` lib tests pass (142/142).

## Proof of concept
A unit test in `crates/anymd/src/lib.rs` `mod tests`, modelled on the existing `all_tool_entrypoints_reject_paths_outside_the_native_allowlist` and using `SourceAccessPolicy::restricted_for_test`. The allowlist is an empty temp directory; the two PDFs are the repo's own fixtures, which sit outside it.

```rust
#[tokio::test]
async fn poc_pdf_compare_ignores_native_allowlist() {
    let temp = tempfile::tempdir().expect("tempdir");
    let allowed = temp.path().join("allowed");
    std::fs::create_dir(&allowed).expect("allowed root");
    let fixtures = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../test/fixtures");
    let before = fixtures.join("sample.pdf").canonicalize().expect("before");
    let after = fixtures.join("figure-report.pdf").canonicalize().expect("after");
    let policy = crate::source_access::SourceAccessPolicy::restricted_for_test(
        temp.path().to_path_buf(), &allowed).expect("restricted policy");
    let server = PdfReaderMcp::with_source_access(policy);

    // Control: read_pdf rejects the outside path.
    let read = serde_json::from_value(serde_json::json!({"sources": [{"path": before}]})).unwrap();
    let read_error = server.read_pdf(Parameters(read)).await.expect_err("must reject");
    assert!(read_error.message.contains("Access denied"));

    // pdf_compare opens both outside paths.
    let cmp = serde_json::from_value(serde_json::json!({"before": before, "after": after})).unwrap();
    let result = server.pdf_compare(Parameters(cmp)).await;
    assert!(result.is_ok(), "pdf_compare should have been denied like read_pdf");
}
```

Output on 8.5.4 (commit 07700c78), reproduced 3/3:

```text
POC-CTRL read_pdf outside path -> Access denied: path '.../test/fixtures/sample.pdf' is outside the configured allowed directories.
POC-EXPLOIT pdf_compare outside paths -> ok=true bytes=5731 head=Ok(CallToolResult { ... text: "{\"added_terms\":[\"1\",\"2026\",\"across\",\"and\",\"by\",\"closes\",\"every\",\"figure\",\"grew\", ...
test tests::poc_pdf_compare_ignores_native_allowlist ... ok
```

## Impact
An operator who sets `--allow-dir` / `MCP_PDF_ALLOWED_DIRS` (recommended in README.md and SECURITY.md) expects the server to read only PDFs under those directories. Through `pdf_compare`, anyone who can call tools can read the extracted term sets of any PDF the server process can open outside the allowlist, and probe whether arbitrary paths exist. On the default stdio transport this needs the user's agent to be steered (for example by prompt injection in a processed document); on the opt-in HTTP transport any client that reaches the port, or holds the API key, can do it directly. Disclosure is partial (term sets and document statistics, not the full text), hence the Low confidentiality rating; the maintainers may rate it differently for HTTP deployments.

## References

- https://github.com/SylphxAI/anymd/security/advisories/GHSA-xrc8-gj3q-m8vm

Page: https://cve.now/GHSA-XRC8-GJ3Q-M8VM

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
