How curl was accidentally Turing-complete for nine months
From curl 8.12 through 8.16, config files could slice variable values and include other config files with no explicit depth cap. Together, these features made curl Turing-complete[1] under the usual idealization of unbounded strings and resources: it could simulate any program for a two-counter Minsky machine[2]. A counter value n is represented by n copies of x — {{b}} expands the current value, [0-0] keeps only the first byte (x or empty), and [1-] keeps everything except the first byte. File names act as labels, and expand-config selects the next file. Four files in curl_addition.zip compute 2 + 3 with the expected output A=xxxxx B=, and Jonathan Tremesaygues implemented '99 Bottles of Beer on the Wall' (99_bottles.tar.gz) on the same scheme.
Curl 8.17.0 added a five-level include cap that breaks this reduction[3]. The pull request says the cap prevents a config file from including itself indefinitely; the public explanation does not discuss Turing completeness or why the cap is five. The reduction assumes unbounded counters and unbounded steps, and the real binary has neither: MAX_EXPAND_CONTENT is 10,000,000 bytes (src/var.c), and --config returns only at halt, with every level using a C stack frame and keeping its config file open — in a minimal countdown loop on 8.12, an 8 MB stack allowed 922 steps before a segfault[4]. A Bash while loop can complement bounded curl by invoking a config once per step and carrying the counters and instruction label between invocations, which is a composition rather than curl-alone Turing completeness.
Read the original seriot.chDiscussion
Discussion
Commenters call accidental Turing-completeness 'poetic' and joke about running Doom in curl 8.16. One notes that string rewriting systems easily become Turing-complete by accident — regexes being the classic example — and argues universities should teach that Turing completeness is hard to avoid.
Sources
-
seriot.ch
How curl was accidentally Turing-complete for nine months
-
KRGeekNews KO
curl이 우연히 9개월 동안 튜링 완전했던 과정


