Skip to content
Tcl Source Code Artifact [a7028def52]
Login

Artifact [a7028def52]

Artifact a7028def52a4f579465ad9782f0c6e282bf25d0d:

Ticket change [a7028def52] - New ticket [3606139fffffffff|3606139fff] <i>missing error check allows regexp to crash Tcl</i>. by tgl on 2013-02-26 23:47:28.
D 2013-02-26T23:47:28
J assignee pvgoran
J cmimetype text/plain
J comment The\sattached\stest\scase\scrashes\sthe\slatest\stclsh\sI\shave\shandy\s(8.5.11)\n\nThis\sis\sderived\sfrom\sa\stest\scase\sthat\swas\ssent\sto\sthe\sPostgres\ssecurity\slist.\s\sThe\sPostgres\sproject\sis\scurrently\sthinking\sof\streating\sthis\sas\sjust\sa\sregular\sbug\sand\snot\sa\ssecurity\sissue,\sbecause\sas\sfar\sas\swe\scan\stell\sthe\spotential\sdamage\sis\slimited\sto\sa\snull-pointer\sdereference.\s\sBut\swe\sthought\swe'd\slet\syou\sknow\sabout\sit\sfirst\sto\ssee\sif\syou\sfeel\sit\sneeds\sto\sbe\streated\sas\sa\ssecurity\sissue.\s\sIf\sso,\swe'll\sneed\sto\sorganize\scoordinated\sreleases.\n\nHere's\sthe\sanalysis\sI\ssent\sto\sthe\sPostgres\ssecurity\slist:\n\nI\slooked\sinto\sthis,\sand\sfind\sthat\sthe\score\sof\sthe\sproblem\sis\sthat\nparseqatom()\sis\snot\sdefending\sitself\sagainst\sa\sNULL\sresult\sfrom\nparsebranch().\s\sSee\sthis\sbit\sof\scode:\n\n\s\s\s\sif\s(!(SEE('|')\s||\sSEE(stopper)\s||\sSEE(EOS)))\n\s\s\s\s\s\s\s\st->right\s=\sparsebranch(v,\sstopper,\stype,\ss2,\srp,\s1);\n\s\s\s\selse\n\s\s\s\s{\n\s\s\s\s\s\s\s\sEMPTYARC(s2,\srp);\n\s\s\s\s\s\s\s\st->right\s=\ssubre(v,\s'=',\s0,\ss2,\srp);\n\s\s\s\s}\n\s\s\s\sassert(SEE('|')\s||\sSEE(stopper)\s||\sSEE(EOS));\n\s\s\s\st->flags\s|=\sCOMBINE(t->flags,\st->right->flags);\n\nIf\sparsebranch\s(or\ssubre\sfor\sthat\smatter)\sreturns\sNULL,\sthe\nt->right->flags\sreference\swill\sobviously\scrash.\n\nIt\sturns\sout\sthat\sparsebranch\susually\sreturns\sa\svalid\sstruct\ssubre\npointer\seven\safter\san\serror,\sbut\sit\shas\stwo\s"NOERRN()"\smacros\n(essentially\s"if\s(error\soccurred)\sreturn\sNULL")\sin\splaces\swhere\sonly\nan\sout-of-memory\sor\sregex-too-complex\serror\swould\strigger\sthe\serror\nresponse.\s\sThis\sexample\scase\sis\sprovoking\sthe\sregex-too-complex\serror.\n\nThis\sbug\sis\saboriginal\sin\sSpencer's\scode.\s\sThe\sreason\swe've\snot\sseen\sit\nreported\sbefore\sappears\sto\sbe\s(a)\stypical\serrors\ssuch\sas\sregex\ssyntax\nerrors\sdon't\send\sup\sreturning\sNULL\sfrom\sparsebranch,\sand\s(2)\syou\sdon't\nget\sto\sthe\svulnerable\scode\sin\sparseqatom\sunless\sthe\sregex\shas\sbeen\sfound\nto\scontain\s"messy\sstuff"\s(capturing\sparens,\sback\sreference,\sor\nshort/long\spreference\sclash).\n\nThe\sattached\spatch\sfixes\sit.\s\sThe\sadded\serror\scheck\sin\sparseqatom()\sis\nthe\snecessary\sfix,\sthe\sadditional\scheck\sin\sparsebranch()\sis\sjust\nintended\sto\snot\slet\sprocessing\scontinue\safter\swe\sknow\sthere's\san\serror.\n\nI'm\snot\ssure\swhether\swe\sshould\streat\sthis\sas\sa\ssecurity\sproblem\sor\sjust\nfix\sit\sand\sbe\sdone.\s\sAFAICS\sthere\sis\sno\srisk\sof\sanything\sworse\sthan\sa\nnull\spointer\sdereference\s(no\spossibility\sof\sprivilege\sescalation\sor\ninformation\sleakage).\s\sWe've\sbeen\sless\sthan\sconsistent\sin\sthe\spast\sas\sto\nhow\sto\sdeal\swith\ssimple\scrash\scases\slike\sthis;\ssome\shave\sbeen\streated\sas\nsecurity\sissues,\sbut\smany\smore\shave\sjust\sbeen\shandled\sas\sordinary\sbugs.\n\n\nBTW,\scredit\sfor\sfinding\sthis\sissue\sgoes\sto\sTomasz\sKarlik\s<[email protected]>\n
J foundin obsolete:\s8.5.11
J is_private 1
J priority 5\sMedium
J resolution None
J status Open
J submitter tgl
J subsystem 43.\sRegexp
J title missing\serror\scheck\sallows\sregexp\sto\scrash\sTcl
J type Bug
K 3606139fffffffffffffffffffffffffffffffff
U tgl
Z bfb1574a966ef5fb445081042011c641