Skip to content
Tcl Source Code Artifact [e5efe114aa]
Login

Artifact [e5efe114aa]

Artifact e5efe114aa4ed46a96e2fb2789787b032793162449e713eb7208135a7d4fd994:

Ticket change [e5efe114aa] - Ticket [344b1a0c0f0e2fda|344b1a0c0f] <i>exec on Windows broken when &#39;%&#39; is used</i> status still Open with 3 other changes by sebres on 2019-01-17 09:00:11.
D 2019-01-17T09:00:11.512
J icomment <p>Just\sfor\sthe\srecord</p>\r\n<p>As\sfor\s[pwd]\snormalization...<br>Well,\sas\salready\ssaid,\sI\sdon't\sthink\sit\sis\sstill\san\sissue\sunder\swindows.</p>\r\n<p>As\sfor\s"the\spercent\scharacter\shas\sto\sbe\sescaped"...\s<br>Sure\sit\smust\sbe,\sbut\sfor\sbatch/exe,\sand\sas\sregards\sthe\sexecution\sof\scommand\sprocessor\s-\sit\swas\sjust\sunintended\safter-effect\sof\sthe\sfix.\sShit\shappens.<br>The\sescape\sis\snecessary\sbecause\sof\scertain\sissue\show\sWindows\sprocesses\sunpaired\squotes\s(it\sis\svulnerable\sat\sthe\smoment\sand\sMS\swon't\sfix\sthis\sdue\sto\scompat-reasons,\ssee\s<a\shref="https://github.com/Microsoft/console/issues/250">Microsoft/console/issues/250)</a>,\sso\sit\sis\spossible\sto\sproduce\san\sunpaired\squote\safter\ssubstitution\sof\ssome\senv-vars\s(like\spaths,\scontaining\squotes,\swhich\sare\ssubstituted\sin\scall,\sso\sno\smore\sunder\scontrol\sof\sTcl).\sJust\sbecause\sseveral\squotation\smarks\stogether\sare\sprocessed\sdifferently,\sthere\sare\seven\sweird\scases\swhere\striple-quotes\swill\sbe\sunescaped\ssimilar\sto\sdouble-quotes,\sor\sthey\scan\seven\s"reverse"\sunescape\sstrategy\sMS\sused\shere.\s<br>For\sexample\s<code>C"\s"C</code>,\s<code>"C\sC"</code>\sand\s<code>""C"\s"C""</code>\sare\sthe\ssame\sunder\swindows,\sso\sfollowing\ssubstitutions\scause\sthe\ssame\sresult:</p>\r\n<p><pre\sstyle="font-size:\s80%">\r\n&gt;\secho\sputs\s$::argv\s|\stclsh\s-\sC"\s"C\r\n-\s{C\sC}\r\n&gt;\secho\sputs\s$::argv\s|\stclsh\s-\s"C\sC"\r\n-\s{C\sC}\r\n&gt;\secho\sputs\s$::argv\s|\stclsh\s-\s""C"\s"C""\r\n-\s{C\sC}\r\n</pre>\r\nSo\sif\syou\sbasically\sdon't\shave\sthe\squotes\sunder\syour\scontrol\sand\sin\sprinciple\syou\sdo\snot,\sbecause\sthe\sinternal\s%-substitution\sof\svariables\shas\sprecedence\shere,\sso\scould\sdamn\syour\scomposited\scommand\sline,\salso\sin\scase\sit\swas\sinitially\squoted\sproperly.<br>Then\sthe\susage\sof\ssome\sparameters\slike\s"|\s%COMSPEC%\s/c\sdo-something-evil"\safter\ssuch\sbreak,\se.\sg.\spassed\sfrom\sforeign\suser-input\sand\snormally\sproper\squoted/escaped\sas\sregards\sthe\ssingle\sargument,\sallow\sintruder\sto\sconstruct\san\sinjection\sand\sproduce\sexploit.<br><br>That's\sas\sregards\sthe\sbatch-execution\setc.<br>As\salready\ssaid,\scmd\s/c\sis\srather\san\sexception\shere\s(and\swas\sjust\san\safter-effect,\sso\sblame\son\sme),\sbut\sI'll\stry\sto\sprovide\sthe\sfix\sas\ssoon\sas\spossible.</p>\r\n<p>As\sfor\s"don't\sthink\sthat\scould\sbe\saccomplished\susing\sdouble\squotes".\sYes\syou\sare\sright,\sit\sis\snot\sreally\spossible,\sand\sthis\sis\salso\sexplained\sin\s<a\shref="https://core.tcl-lang.org/tcl/info/cc35e8ac4d9f98e6">my\slast\scomment</a>\sto&nbsp;mentioned\s0-day\svulni-ticket\s(but\sit\sis\sat\sleast\ssecurer\sas\sit\swas\spreviously).<br>The\smagic\sword\shere\sis\scircumflex\s(^)\scharacter\sand\sI've\salready\spotential\ssolution\sfor\sthis,\sjust\sthe\smixed\sescape\susing\scircumflex\sand\squotes\stogether\sis\sa\sbit\scomplex\s(see\s<a\shref="https://github.com/sebres/PoC/issues/1">sebres/PoC/issues/1</a>).\s<br>Additionally\sit\sdeviates\sa\sbit\sby\sthe\scall\sof\sbatch\sand\sexecutable,\sand\sI\swould\sresolve\sthis\sdeviation\sbefore,\sas\swell\sas\sprovide\sgood\stest-coverage\sfor\sboth\svariants\s(now\s3,\sinclusive\scomspec).</p>\r\n<p>17.01.2019\s01:19,\sJoe\sMistachkin\swrote:</p>\r\n<blockquote\stype="cite"\sstyle="padding-left:\s5px;\sborder-left:\s#1010ff\s2px\ssolid;\smargin-left:\s5px">\r\n<div\sdir="ltr">\r\n<div>The\soriginal\sproblem\sbeing\ssolved\swas\sthat\s[pwd]\sdid\snot\spreserve\sthe\sexact\scase\sof\sthe\scurrent\sdirectory.&nbsp;\sI'm\sstruggling\sto\srecall,\sbut\sI\sthink\smaking\sthe\stest\sresult\scomparison\scase-insensitive\swas\snot\san\sappropriate\soption.</div>\r\n<div>&nbsp;</div>\r\n<div>That\sbeing\ssaid,\sgiven\sthe\scommand\sescaping\salgorithm\sin\suse\sfor\sWindows\s[exec]\sin\s8.6.9,\sI'm\ssurprised\sthat\sother\speople\shaven't\snoticed\sthat\sthings\sdon't\swork\squite\sthe\ssame.&nbsp;\sAlso,\sI'm\sconfused\sby\sthe\spercent\scharacter\shas\sto\sbe\sescaped,\ssince\sit\sdoes\snot\stypically\simpact\sargument\sboundaries\son\sWindows.&nbsp;\sFurthermore,\s*if*\sit\shad\sto\sbe\sescaped,\sI\sdon't\sthink\sthat\scould\sbe\saccomplished\susing\sdouble\squotes.</div>
J login sebres
J mimetype text/html
K 344b1a0c0f0e2fda1e4ad6520cbf5e0af35eb332
U sebres
Z 1ba049466a468d39e115a65b7416b4c4