{"article":{"slug":"how-curl-was-accidentally-turing-complete-for-nine-months","title":"How curl was accidentally Turing-complete for nine months","subtitle":null,"summary":"Nicolas Seriot shows that from curl 8.12 through 8.16, config-file variable slicing plus uncapped config includes let curl simulate any two-counter Minsky machine, making it Turing-complete in principle until curl 8.17.0 added a five-level include cap.","content_type":"research","language":"en","canonical_url":"https://seriot.ch/computation/curl.html","author":{"name":"Nicolas Seriot","url":null,"person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"Nicolas Seriot","url":"https://seriot.ch/","listing_slug":null,"listing":null},"topics":[{"name":"programming","slug":"programming","url":"https://listedarticles.com/topics/programming"},{"name":"developer-tools","slug":"developer-tools","url":"https://listedarticles.com/topics/developer-tools"},{"name":"algorithms","slug":"algorithms","url":"https://listedarticles.com/topics/algorithms"},{"name":"open-source","slug":"open-source","url":"https://listedarticles.com/topics/open-source"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":457,"reading_minutes":2,"published_at":"2026-10-29T00:00:00.000Z","added_at":"2026-10-30T08:15:02.044Z","updated_at":"2026-10-30T08:15:02.044Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":true},"profile_url":"https://listedarticles.com/articles/how-curl-was-accidentally-turing-complete-for-nine-months","markdown_url":"https://listedarticles.com/articles/how-curl-was-accidentally-turing-complete-for-nine-months.md","example":false,"citation":"Nicolas Seriot, Nicolas Seriot. \"How curl was accidentally Turing-complete for nine months.\" 29 Oct 2026. https://seriot.ch/computation/curl.html (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://seriot.ch/computation/curl.html"},"body_markdown":"*29th October 2026*\n\nFrom curl 8.12 through 8.16, config files could slice variable values and include other config files without an explicit depth cap. Together, these features let curl simulate any two-counter Minsky program. Under the usual idealization of unbounded strings and resources, this construction was Turing-complete.\n\nCurl 8.17.0 added a five-level include cap that breaks this reduction.\n\n### Minsky 2-Counter Reduction\n\nA counter value `n` is represented by `n` copies of `x`.\n\nEach instruction state uses one or more config files, with file names acting as labels, and `expand-config` selecting the next file.\n\nSyntax:\n\n- `{{b}}` expands the current value\n- `[0-0]` keeps only the first byte (`x` or empty)\n- `[1-]` keeps everything except the first byte\n- empty slices yield empty strings ([doc](https://github.com/curl/curl/blob/curl-8_12_0/docs/cmdline-opts/variable.md))\n\n| Minsky | Curl config |\n| --- | --- |\n| Register `R` | Variable `r` (`R` is the number of `x` bytes) |\n| `INC(R)` | `expand-variable = \"r={{r}}x\"` |\n| `DEC(R)` | `expand-variable = \"r[1-]={{r}}\"` |\n| `JZ(R, _, _x)` | `expand-variable = \"t[0-0]={{r}}\"` `expand-config = \"state_{{t}}.conf\"` |\n| `JMP(S)` | `expand-config = \"S.conf\"` |\n| Halt | No further `expand-config` |\n\nWith that, we can compile any two-counter program into curl config files.\n\n### PoC: Adding 2 + 3\n\nFour files in [curl\\_addition.zip](https://seriot.ch/resources/curl_addition.zip) compute 2 + 3.\n\n![](https://seriot.ch/resources/curl_config.png)\n\nBuild a local curl 8.12.0 binary if needed:\n\n```\nmkdir -p /tmp/curl-tc-build\ncd /tmp/curl-tc-build\ncurl -fsSLO https://curl.se/download/curl-8.12.0.tar.gz\ntar -xzf curl-8.12.0.tar.gz\ncd curl-8.12.0\n./configure --without-ssl --disable-shared --disable-manual --disable-docs\nmake -j4\n```\n\nThen, from the `addition/` directory, run:\n\n```\n/tmp/curl-tc-build/curl-8.12.0/src/curl -q -s -K main.conf\n```\n\nExpected output:\n\n```\nA=xxxxx B=\n```\n\n### Runtime Bounds\n\nThe reduction assumes unbounded counters and unbounded steps. The real binary has neither:\n\n- **Expanded content (curl's own limit).** Each expansion is capped at `MAX_EXPAND_CONTENT` = 10,000,000 bytes ([`src/var.c`](https://github.com/curl/curl/blob/curl-8_12_0/src/var.c#L42)).\n- **Step count.** There is no loop: each step is a nested `--config` that returns only at halt. Every level uses a C stack frame and keeps its config file open until it finishes. In a minimal countdown loop on 8.12, an 8 MB stack allowed 922 steps before a segfault.\n- **Retained variable versions.** Reassignment [adds a new entry](https://github.com/curl/curl/blob/curl-8_12_0/src/var.c#L347-L370) while retaining the old one until [cleanup](https://github.com/curl/curl/blob/curl-8_12_0/src/var.c#L58-L78). Memory use and some variable lookups grow with the number of steps.\n\n### History and Version Support\n\n- curl 8.3 (2023-09): Variables expansion\n- curl 8.12 (2025-02): Byte-range assignment\n- curl 8.17 (2025-11): [five-level cap](https://github.com/curl/curl/blob/curl-8_17_0/src/tool_parsecfg.h#L28-L30) defeats the reduction\n\nThe [pull request](https://github.com/curl/curl/pull/19168) says the cap prevents a config file from including itself indefinitely. Its [regression test](https://github.com/curl/curl/blob/curl-8_17_0/tests/data/test774) does exactly that and expects an error. The public explanation does not discuss Turing completeness or why the cap is five.\n\nA Bash `while` loop can complement bounded curl by invoking a config once per step and carrying the counters and instruction label between invocations. The repetition then comes from Bash, so this is a composition rather than curl-alone Turing completeness.\n\n### Security impact\n\nNone.\n","body_html":"<p><em>29th October 2026</em></p>\n<p>From curl 8.12 through 8.16, config files could slice variable values and include other config files without an explicit depth cap. Together, these features let curl simulate any two-counter Minsky program. Under the usual idealization of unbounded strings and resources, this construction was Turing-complete.</p>\n<p>Curl 8.17.0 added a five-level include cap that breaks this reduction.</p>\n<h3 id=\"minsky-2-counter-reduction\">Minsky 2-Counter Reduction</h3>\n<p>A counter value <code>n</code> is represented by <code>n</code> copies of <code>x</code>.</p>\n<p>Each instruction state uses one or more config files, with file names acting as labels, and <code>expand-config</code> selecting the next file.</p>\n<p>Syntax:</p>\n<ul><li><code>{{b}}</code> expands the current value</li><li><code>[0-0]</code> keeps only the first byte (<code>x</code> or empty)</li><li><code>[1-]</code> keeps everything except the first byte</li><li>empty slices yield empty strings (<a href=\"https://github.com/curl/curl/blob/curl-8_12_0/docs/cmdline-opts/variable.md\" rel=\"nofollow ugc noopener\">doc</a>)</li></ul>\n<div class=\"table-wrap\"><table><thead><tr><th>Minsky</th><th>Curl config</th></tr></thead><tbody><tr><td>Register <code>R</code></td><td>Variable <code>r</code> (<code>R</code> is the number of <code>x</code> bytes)</td></tr><tr><td><code>INC(R)</code></td><td><code>expand-variable = &quot;r={{r}}x&quot;</code></td></tr><tr><td><code>DEC(R)</code></td><td><code>expand-variable = &quot;r[1-]={{r}}&quot;</code></td></tr><tr><td><code>JZ(R, _, _x)</code></td><td><code>expand-variable = &quot;t[0-0]={{r}}&quot;</code> <code>expand-config = &quot;state_{{t}}.conf&quot;</code></td></tr><tr><td><code>JMP(S)</code></td><td><code>expand-config = &quot;S.conf&quot;</code></td></tr><tr><td>Halt</td><td>No further <code>expand-config</code></td></tr></tbody></table></div>\n<p>With that, we can compile any two-counter program into curl config files.</p>\n<h3 id=\"poc-adding-2-3\">PoC: Adding 2 + 3</h3>\n<p>Four files in <a href=\"https://seriot.ch/resources/curl_addition.zip\" rel=\"nofollow ugc noopener\">curl_addition.zip</a> compute 2 + 3.</p>\n<figure><img src=\"https://seriot.ch/resources/curl_config.png\" alt=\"\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>Build a local curl 8.12.0 binary if needed:</p>\n<pre><code>mkdir -p /tmp/curl-tc-build\ncd /tmp/curl-tc-build\ncurl -fsSLO https://curl.se/download/curl-8.12.0.tar.gz\ntar -xzf curl-8.12.0.tar.gz\ncd curl-8.12.0\n./configure --without-ssl --disable-shared --disable-manual --disable-docs\nmake -j4</code></pre>\n<p>Then, from the <code>addition/</code> directory, run:</p>\n<pre><code>/tmp/curl-tc-build/curl-8.12.0/src/curl -q -s -K main.conf</code></pre>\n<p>Expected output:</p>\n<pre><code>A=xxxxx B=</code></pre>\n<h3 id=\"runtime-bounds\">Runtime Bounds</h3>\n<p>The reduction assumes unbounded counters and unbounded steps. The real binary has neither:</p>\n<ul><li><strong>Expanded content (curl&#39;s own limit).</strong> Each expansion is capped at <code>MAX_EXPAND_CONTENT</code> = 10,000,000 bytes (<a href=\"https://github.com/curl/curl/blob/curl-8_12_0/src/var.c#L42\" rel=\"nofollow ugc noopener\"><code>src/var.c</code></a>).</li><li><strong>Step count.</strong> There is no loop: each step is a nested <code>--config</code> that returns only at halt. Every level uses a C stack frame and keeps its config file open until it finishes. In a minimal countdown loop on 8.12, an 8 MB stack allowed 922 steps before a segfault.</li><li><strong>Retained variable versions.</strong> Reassignment <a href=\"https://github.com/curl/curl/blob/curl-8_12_0/src/var.c#L347-L370\" rel=\"nofollow ugc noopener\">adds a new entry</a> while retaining the old one until <a href=\"https://github.com/curl/curl/blob/curl-8_12_0/src/var.c#L58-L78\" rel=\"nofollow ugc noopener\">cleanup</a>. Memory use and some variable lookups grow with the number of steps.</li></ul>\n<h3 id=\"history-and-version-support\">History and Version Support</h3>\n<ul><li>curl 8.3 (2023-09): Variables expansion</li><li>curl 8.12 (2025-02): Byte-range assignment</li><li>curl 8.17 (2025-11): <a href=\"https://github.com/curl/curl/blob/curl-8_17_0/src/tool_parsecfg.h#L28-L30\" rel=\"nofollow ugc noopener\">five-level cap</a> defeats the reduction</li></ul>\n<p>The <a href=\"https://github.com/curl/curl/pull/19168\" rel=\"nofollow ugc noopener\">pull request</a> says the cap prevents a config file from including itself indefinitely. Its <a href=\"https://github.com/curl/curl/blob/curl-8_17_0/tests/data/test774\" rel=\"nofollow ugc noopener\">regression test</a> does exactly that and expects an error. The public explanation does not discuss Turing completeness or why the cap is five.</p>\n<p>A Bash <code>while</code> loop can complement bounded curl by invoking a config once per step and carrying the counters and instruction label between invocations. The repetition then comes from Bash, so this is a composition rather than curl-alone Turing completeness.</p>\n<h3 id=\"security-impact\">Security impact</h3>\n<p>None.</p>","headings":[{"level":3,"text":"Minsky 2-Counter Reduction","id":"minsky-2-counter-reduction"},{"level":3,"text":"PoC: Adding 2 + 3","id":"poc-adding-2-3"},{"level":3,"text":"Runtime Bounds","id":"runtime-bounds"},{"level":3,"text":"History and Version Support","id":"history-and-version-support"},{"level":3,"text":"Security impact","id":"security-impact"}]}}