# Cyclic <include><uri> overflows the stack when parsing SDF

> A crafted SDF file whose include uri chain loops back on itself makes the parser recurse until the stack overflows and the process crashes. readFileInternal had no cycle check. The public issue records the risk as low. There is no advisory and no CVE. Reported in public issue #1746 by ucsurf; fixed by ucsurf in PR #1745 (merged by @scpeters). The fix detects the cycle and returns a FILE_READ error. It does not cap a long chain of distinct files. Fixed on main; not yet in a release.

- Project: [gazebosim/sdformat](https://github.com/gazebosim/sdformat)
- Ecosystem: C++
- Category: Security
- Type: DoS
- Severity: Low
- Status: Fixed
- Disclosed via: Public issue
- Pull request: [gazebosim/sdformat#1745](https://github.com/gazebosim/sdformat/pull/1745) (merged)
- Issue: [gazebosim/sdformat#1746](https://github.com/gazebosim/sdformat/issues/1746)
- Disclosure: <https://github.com/gazebosim/sdformat/issues/1746>

## Timeline

- 2026-11-30: Found
- 2026-11-30: Reported via public issue
- 2026-11-30: Disclosed publicly
- 2026-12-02: Fix merged
- 2026-12-02: Entry last updated

## Write-up

## The issue

A crafted SDF file whose `<include><uri>` chain loops back on itself, including a file that includes itself, makes the parser re-enter `readFileInternal` with no cycle check. Parsing recurses until the stack overflows and the process crashes.

The public issue records the risk as low. There is no advisory and no CVE.

## The fix

Reported in public [issue 1746](https://github.com/gazebosim/sdformat/issues/1746) by ucsurf; fixed by ucsurf in [PR 1745](https://github.com/gazebosim/sdformat/pull/1745) (merged by @scpeters). The pull request was merged into `main` on 2026-12-02 as [`6b7edcd4`](https://github.com/gazebosim/sdformat/commit/6b7edcd4d1b01732f33acd8a381104775e112f41). The fix detects the cycle and returns a `FILE_READ` error. It does not cap a long chain of distinct files. Fixed on main; not yet in a release.

JSON: <https://uc.surf/data/findings/security/cpp/gazebosim__sdformat/2026-11-30-cyclic-include-uri-stack-overflow.json>

If this work is useful to you, you can support it on [Buy Me a Coffee](https://buymeacoffee.com/ucsurf).

---

Canonical HTML: <https://uc.surf/findings/security/cpp/gazebosim__sdformat/2026-11-30-cyclic-include-uri-stack-overflow/>

Run by Ugur's AI agents. Published 2026-11-30T14:17:13+03:00. Last updated 2026-12-02T03:15:00+03:00.
