File size: 33,995 Bytes
fbb9bfa
 
 
 
 
 
1
2
3
4
5
6
7
{"messages": [{"content": "You are a security engineer fixing a CVE. You are given the vulnerability description (symptom only) and the vulnerable source window. Author the MINIMAL fix as a unified diff. Follow these rules exactly:\n1. Target ONLY the file named in the `# Vulnerable source (...)` header \u2014 do not invent or substitute file paths.\n2. Modify ONLY code visible in the shown source window.\n3. Change as few lines as possible; do not rewrite surrounding logic.\n4. Output only the unified diff with no other text.\n5. Prefer the minimal structural change: if an existing condition is missing a check, add it inline to that condition rather than inserting a new code block. If existing code is redundant or overcomplicated, replace it \u2014 do not add more code around it.\n6. Edit the most specific method or class that directly handles the vulnerable operation \u2014 not a base class, interface, or Protocol definition.", "role": "system"}, {"content": "# CVE\nCVE-2022-46908: Authorization bypass in SQLite 3.40.0 shell safe-mode: the authorizer callback for SQL function invocations used the wrong argument variable when comparing against the prohibited-functions list, allowing normally-blocked functions to execute.\n\n# Vulnerable source (shell.c)\n```c\n**    recoverAssertMutexHeld()  -   Assert that the recovery mutex is held\n*/\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0\n# define recoverEnterMutex()\n# define recoverLeaveMutex()\n#else\nstatic void recoverEnterMutex(void){\n  sqlite3_mutex_enter(sqlite3_mutex_alloc(RECOVER_MUTEX_ID));\n}\nstatic void recoverLeaveMutex(void){\n  sqlite3_mutex_leave(sqlite3_mutex_alloc(RECOVER_MUTEX_ID));\n}\n#endif\n#if SQLITE_THREADSAFE+0>=1 && defined(SQLITE_DEBUG)\nstatic void recoverAssertMutexHeld(void){\n  assert( sqlite3_mutex_held(sqlite3_mutex_alloc(RECOVER_MUTEX_ID)) );\n}\n#else\n# define recoverAssertMutexHeld()\n#endif\n\n\n/*\n** Like strlen(). But handles NULL pointer arguments.\n*/\nstatic int recoverStrlen(const char *zStr){\n  if( zStr==0 ) return 0;\n  return (int)(strlen(zStr)&0x7fffffff);\n}\n\n/*\n** This function is a no-op if the recover handle passed as the first \n** argument already contains an error (if p->errCode!=SQLITE_OK). \n**\n** Otherwise, an attempt is made to allocate, zero and return a buffer nByte\n** bytes in size. If successful, a pointer to the new buffer is returned. Or,\n** if an OOM error occurs, NULL is returned and the handle error code\n** (p->errCode) set to SQLITE_NOMEM.\n*/\nstatic void *recoverMalloc(sqlite3_recover *p, i64 nByte){\n  void *pRet = 0;\n  assert( nByte>0 );\n  if( p->errCode==SQLITE_OK ){\n    pRet = sqlite3_malloc64(nByte);\n    if( pRet ){\n      memset(pRet, 0, nByte);\n    }else{\n      p->errCode = SQLITE_NOMEM;\n    }\n  }\n  return pRet;\n}\n\n/*\n** Set the error code and error message for the recover handle passed as\n```", "role": "user"}, {"content": "diff --git a/shell.c b/shell.c\n--- a/shell.c\n+++ b/shell.c\n@@ -12921,7 +12921,7 @@ static int safeModeAuth(\n     \"zipfile\",\n     \"zipfile_cds\",\n   };\n-  UNUSED_PARAMETER(zA2);\n+  UNUSED_PARAMETER(zA1);\n   UNUSED_PARAMETER(zA3);\n   UNUSED_PARAMETER(zA4);\n   switch( op ){\n@@ -12936,7 +12936,7 @@ static int safeModeAuth(\n     case SQLITE_FUNCTION: {\n       int i;\n       for(i=0; i<ArraySize(azProhibitedFunctions); i++){\n-        if( sqlite3_stricmp(zA1, azProhibitedFunctions[i])==0 ){\n+        if( sqlite3_stricmp(zA2, azProhibitedFunctions[i])==0 ){\n           failIfSafeMode(p, \"cannot use the %s() function in safe mode\",\n                          azProhibitedFunctions[i]);\n         }", "role": "assistant"}]}
{"messages": [{"content": "You are a security engineer fixing a CVE. You are given the vulnerability description (symptom only) and the vulnerable source window. Author the MINIMAL fix as a unified diff. Follow these rules exactly:\n1. Target ONLY the file named in the `# Vulnerable source (...)` header \u2014 do not invent or substitute file paths.\n2. Modify ONLY code visible in the shown source window.\n3. Change as few lines as possible; do not rewrite surrounding logic.\n4. Output only the unified diff with no other text.\n5. Prefer the minimal structural change: if an existing condition is missing a check, add it inline to that condition rather than inserting a new code block. If existing code is redundant or overcomplicated, replace it \u2014 do not add more code around it.\n6. Edit the most specific method or class that directly handles the vulnerable operation \u2014 not a base class, interface, or Protocol definition.", "role": "system"}, {"content": "# CVE\nCVE-2025-31162: Buffer overflow in fig2dev 3.2.9a (CWE-122): the patterned-line drawing code computes buffer allocations based on the dash-pattern length field of line objects without enforcing an upper bound. A crafted .fig file containing a line object with an abnormally large dash-pattern value can trigger a heap buffer overflow, leading to memory corruption or a crash. The COMMON_PROPERTIES macro checked only that the pattern length was non-negative, omitting the missing upper-bound guard that this patch introduces.\n\n# Vulnerable source (fig2dev/object.h)\n```c\n */\n\n#ifndef OBJECT_H\n#define OBJECT_H\n\n#include <limits.h>\t/* INT_MIN, INT_MAX */\n\n#define\t\tBLACK_COLOR\t0\n#define\t\tWHITE_COLOR\t7\n\n#define\t\tDEFAULT\t\t(-1)\n/* for GIF files */\n#define\t\tMAXCOLORMAPSIZE\t256\n\n#define NUMSHADES\t21\n#define NUMTINTS\t20\n#define NUMPATTERNS\t22\n#define\tNUMFILLS\t40\t/* for convenience, NUMSHADES + NUMTINTS - 1 */\n\ntypedef struct f_point {\n\tint\t\t\tx, y;\n\tstruct f_point\t\t*next;\n} F_point;\n\ntypedef struct f_pos {\n\tint\t\t\tx, y;\n} F_pos;\n#define COORD_MIN\tINT_MIN\n#define COORD_MAX\tINT_MAX\n\ntypedef struct f_arrow {\n\tint\t\t\ttype;\n\tint\t\t\tstyle;\n\tdouble\t\t\tthickness;\n\tdouble\t\t\twid;\n\tdouble\t\t\tht;\n} F_arrow;\n\ntypedef struct f_comment {\n\tchar\t\t\t*comment;\n\tstruct f_comment\t*next;\n} F_comment;\n\n#define COMMON_PROPERTIES(o)\t\t\t\t\t\t\\\n\to->style < SOLID_LINE || o->style > DASH_3_DOTS_LINE ||\t\t\\\n\to->thickness < 0 || o->depth < 0 || o->depth > 999 ||\t\t\\\n\to->fill_style < UNFILLED ||\t\t\t\t\t\\\n\to->fill_style >= NUMSHADES + NUMTINTS + NUMPATTERNS ||\t\t\\\n\to->style_val < 0.0\n\ntypedef struct f_ellipse {\n\tint\t\t\ttype;\n#define\t\tT_ELLIPSE_BY_RAD\t1\n#define\t\tT_ELLIPSE_BY_DIA\t2\n#define\t\tT_CIRCLE_BY_RAD\t\t3\n#define\t\tT_CIRCLE_BY_DIA\t\t4\n\tint\t\t\tstyle;\n\tint\t\t\tthickness;\n\tint\t\t\tpen_color;\n\tint\t\t\tfill_color;\n\tint\t\t\tdepth;\n\tint\t\t\tpen;\n\tint\t\t\tfill_style;\n\tdouble\t\t\tstyle_val;\n\tint\t\t\tdirection;\n\tdouble\t\t\tangle;\n#define\t\tUNFILLED\t-1\n#define\t\tWHITE_FILL\t0\n#define\t\tBLACK_FILL\t20\n\tstruct f_pos\t\tcenter;\n\tstruct f_pos\t\tradiuses;\n\tstruct f_pos\t\tstart;\n\tstruct f_pos\t\tend;\n\tstruct f_comment\t*comments;\n\tstruct f_ellipse\t*next;\n} F_ellipse;\n\n#define INVALID_ELLIPSE(e)\t\\\n\te->type < T_ELLIPSE_BY_RAD || e->type > T_CIRCLE_BY_DIA ||\t\\\n\tCOMMON_PROPERTIES(e) || (e->direction != 1 && e->direction != 0) || \\\n\te->radiuses.x == 0 || e->radiuses.y == 0 || \\\n\te->angle < -7. || e->angle > 7.\n\ntypedef struct f_arc {\n\tint\t\t\ttype;\n#define\t\tT_OPEN_ARC\t\t1\n#define\t\tT_PIE_WEDGE_ARC\t\t2\n\tint\t\t\tstyle;\n\tint\t\t\tthickness;\n\tint\t\t\tpen_color;\n\tint\t\t\tfill_color;\n\tint\t\t\tdepth;\n```", "role": "user"}, {"content": "diff --git a/fig2dev/object.h b/fig2dev/object.h\nindex 29f5a62..7f83939 100644\n--- a/fig2dev/object.h\n+++ b/fig2dev/object.h\n@@ -57,12 +57,13 @@ typedef struct f_comment {\n \tstruct f_comment\t*next;\n } F_comment;\n \n+#define\tSTYLE_VAL_MAX\t6400.0\t/* dash length 80 inches, that is enough */\n #define COMMON_PROPERTIES(o)\t\t\t\t\t\t\\\n \to->style < SOLID_LINE || o->style > DASH_3_DOTS_LINE ||\t\t\\\n \to->thickness < 0 || o->depth < 0 || o->depth > 999 ||\t\t\\\n \to->fill_style < UNFILLED ||\t\t\t\t\t\\\n \to->fill_style >= NUMSHADES + NUMTINTS + NUMPATTERNS ||\t\t\\\n-\to->style_val < 0.0\n+\to->style_val < 0.0 || o->style_val > STYLE_VAL_MAX\n \n typedef struct f_ellipse {\n \tint\t\t\ttype;", "role": "assistant"}]}
{"messages": [{"content": "You are a security engineer fixing a CVE. You are given the vulnerability description (symptom only) and the vulnerable source window. Author the MINIMAL fix as a unified diff. Follow these rules exactly:\n1. Target ONLY the file named in the `# Vulnerable source (...)` header \u2014 do not invent or substitute file paths.\n2. Modify ONLY code visible in the shown source window.\n3. Change as few lines as possible; do not rewrite surrounding logic.\n4. Output only the unified diff with no other text.\n5. Prefer the minimal structural change: if an existing condition is missing a check, add it inline to that condition rather than inserting a new code block. If existing code is redundant or overcomplicated, replace it \u2014 do not add more code around it.\n6. Edit the most specific method or class that directly handles the vulnerable operation \u2014 not a base class, interface, or Protocol definition.", "role": "system"}, {"content": "# CVE\nCVE-2025-31163: fig2dev 3.2.9a has an invalid memory access when processing FIG arc objects whose bounding vertices share the same coordinates: the arc validation macro in object.h did not verify whether successive arc control vertices are distinct, so a maliciously crafted FIG file containing an arc where the bounding vertices are identical can cause an exploitable crash in the fig2dev renderer.\n\n# Vulnerable source (fig2dev/object.h)\n```c\n/*\n * Fig2dev: Translate Fig code to various Devices\n * Copyright (c) 1991 by Micah Beck\n * Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul\n * Parts Copyright (c) 1989-2015 by Brian V. Smith\n * Parts Copyright (c) 2015-2023 by Thomas Loimer\n *\n * Any party obtaining a copy of these files is granted, free of charge, a\n * full and unrestricted irrevocable, world-wide, paid up, royalty-free,\n * nonexclusive right and license to deal in this software and documentation\n * files (the \"Software\"), including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense and/or sell copies\n * of the Software, and to permit persons who receive copies from any such\n * party to do so, with the only requirement being that the above copyright\n * and this permission notice remain intact.\n *\n */\n\n#ifndef OBJECT_H\n#define OBJECT_H\n\n#include <limits.h>\t/* INT_MIN, INT_MAX */\n\n#define\t\tBLACK_COLOR\t0\n#define\t\tWHITE_COLOR\t7\n\n#define\t\tDEFAULT\t\t(-1)\n/* for GIF files */\n#define\t\tMAXCOLORMAPSIZE\t256\n\n#define NUMSHADES\t21\n#define NUMTINTS\t20\n#define NUMPATTERNS\t22\n#define\tNUMFILLS\t40\t/* for convenience, NUMSHADES + NUMTINTS - 1 */\n\ntypedef struct f_point {\n\tint\t\t\tx, y;\n\tstruct f_point\t\t*next;\n} F_point;\n\ntypedef struct f_pos {\n\tint\t\t\tx, y;\n} F_pos;\n#define COORD_MIN\tINT_MIN\n#define COORD_MAX\tINT_MAX\n\ntypedef struct f_arrow {\n\tint\t\t\ttype;\n\tint\t\t\tstyle;\n\tdouble\t\t\tthickness;\n\tdouble\t\t\twid;\n\tdouble\t\t\tht;\n} F_arrow;\n\ntypedef struct f_comment {\n\tchar\t\t\t*comment;\n\tstruct f_comment\t*next;\n} F_comment;\n\n#define COMMON_PROPERTIES(o)\t\t\t\t\t\t\\\n\to->style < SOLID_LINE || o->style > DASH_3_DOTS_LINE ||\t\t\\\n\to->thickness < 0 || o->depth < 0 || o->depth > 999 ||\t\t\\\n\to->fill_style < UNFILLED ||\t\t\t\t\t\\\n\to->fill_style >= NUMSHADES + NUMTINTS + NUMPATTERNS ||\t\t\\\n\to->style_val < 0.0\n\ntypedef struct f_ellipse {\n\tint\t\t\ttype;\n#define\t\tT_ELLIPSE_BY_RAD\t1\n#define\t\tT_ELLIPSE_BY_DIA\t2\n#define\t\tT_CIRCLE_BY_RAD\t\t3\n#define\t\tT_CIRCLE_BY_DIA\t\t4\n\tint\t\t\tstyle;\n\tint\t\t\tthickness;\n\tint\t\t\tpen_color;\n\tint\t\t\tfill_color;\n\tint\t\t\tdepth;\n\tint\t\t\tpen;\n\tint\t\t\tfill_style;\n\tdouble\t\t\tstyle_val;\n\tint\t\t\tdirection;\n\tdouble\t\t\tangle;\n#define\t\tUNFILLED\t-1\n#define\t\tWHITE_FILL\t0\n#define\t\tBLACK_FILL\t20\n\tstruct f_pos\t\tcenter;\n\tstruct f_pos\t\tradiuses;\n\tstruct f_pos\t\tstart;\n\tstruct f_pos\t\tend;\n\tstruct f_comment\t*comments;\n\tstruct f_ellipse\t*next;\n} F_ellipse;\n\n#define INVALID_ELLIPSE(e)\t\\\n\te->type < T_ELLIPSE_BY_RAD || e->type > T_CIRCLE_BY_DIA ||\t\\\n\tCOMMON_PROPERTIES(e) || (e->direction != 1 && e->direction != 0) || \\\n\te->radiuses.x == 0 || e->radiuses.y == 0 || \\\n\te->angle < -7. || e->angle > 7.\n\ntypedef struct f_arc {\n\tint\t\t\ttype;\n#define\t\tT_OPEN_ARC\t\t1\n#define\t\tT_PIE_WEDGE_ARC\t\t2\n\tint\t\t\tstyle;\n\tint\t\t\tthickness;\n\tint\t\t\tpen_color;\n\tint\t\t\tfill_color;\n\tint\t\t\tdepth;\n\tint\t\t\tpen;\n\tint\t\t\tfill_style;\n\tdouble\t\t\tstyle_val;\n\tstruct f_arrow\t\t*for_arrow;\n\tstruct f_arrow\t\t*back_arrow;\n\tint\t\t\tcap_style;\n/* IMPORTANT: everything above this point must be in the same order\n\t      for ARC, LINE and SPLINE (LINE has join_style following cap_style */\n\tint\t\t\tdirection;\n\tstruct {double x, y;}\tcenter;\n\tstruct f_pos\t\tpoint[3];\n\tstruct f_comment\t*comments;\n\tstruct f_arc\t\t*next;\n} F_arc;\n\n#define INVALID_ARC(a)\t\\\n\ta->type < T_OPEN_ARC || a->type > T_PIE_WEDGE_ARC ||\t\t\\\n\tCOMMON_PROPERTIES(a) || a->cap_style < 0 || a->cap_style > 2 ||\t\\\n\ta->center.x < COORD_MIN || a->center.x > COORD_MAX ||\t\t\\\n\ta->center.y < COORD_MIN || a->center.y > COORD_MAX ||\t\t\\\n\t(a->direction != 0 && a->direction != 1)\n\ntypedef struct f_line {\n\tint\t\t\ttype;\n#define\t\tT_POLYLINE\t1\n#define\t\tT_BOX\t\t2\n#define\t\tT_POLYGON\t3\n#define\t\tT_ARC_BOX\t4\n#define\t\tT_PIC_BOX\t5\n\tint\t\t\tstyle;\n\tint\t\t\tthickness;\n\tint\t\t\tpen_color;\n\tint\t\t\tfill_color;\n\tint\t\t\tdepth;\n\tint\t\t\tpen;\n\tint\t\t\tfill_style;\n\tdouble\t\t\tstyle_val;\n\tstruct f_arrow\t\t*for_arrow;\n\tstruct f_arrow\t\t*back_arrow;\n\tint\t\t\tcap_style;\n\tstruct f_point\t\t*points;\n/* IMPORTANT: everything above this point must be in the same order\n\t      for ARC, LINE and SPLINE (LINE has join_style following cap_style */\n\tint\t\t\tjoin_style;\n\tint\t\t\tradius;\t/* for T_ARC_BOX */\n\tint\t\t\tnum_points;\n\tstruct f_pos\t\tlast[2]; /* last and penultimate point */\n\tstruct f_pic\t\t*pic;\n\tstruct f_comment\t*comments;\n\tstruct f_line\t\t*next;\n} F_line;\n\n#define INVALID_LINE(l)\t\\\n\tl->type < T_POLYLINE || l->type > T_PIC_BOX || COMMON_PROPERTIES(l) || \\\n\tl->cap_style < 0 || l->cap_style > 2 ||\t\t\t\\\n\tl->join_style < 0 || l->join_style > 2 ||\t\t\\\n\t(l->type == T_ARC_BOX && l->radius < 0)\n\n/* for colormap */\n#define\t\tRED\t0\n#define\t\tGREEN\t1\n#define\t\tBLUE\t2\n/* transparency: an index into the colormap: num_transp > 0, otherwise */\n#define\t\tNO_TRANSPARENCY    0\n#define\t\tTRANSP_COLOR\t (-1)\t/* transparent color given as\n\t\t\t\t\t   rgb triplet */\ntypedef struct f_pic {\n\tint\t\t\tsubtype;\n#define\t\tP_EPS\t0\t\t/* EPS picture type */\n```", "role": "user"}, {"content": "diff --git a/fig2dev/object.h b/fig2dev/object.h\nindex 7f83939..50afbf0 100644\n--- a/fig2dev/object.h\n+++ b/fig2dev/object.h\n@@ -3,7 +3,7 @@\n  * Copyright (c) 1991 by Micah Beck\n  * Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul\n  * Parts Copyright (c) 1989-2015 by Brian V. Smith\n- * Parts Copyright (c) 2015-2023 by Thomas Loimer\n+ * Parts Copyright (c) 2015-2025 by Thomas Loimer\n  *\n  * Any party obtaining a copy of these files is granted, free of charge, a\n  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,\n@@ -92,10 +92,10 @@ typedef struct f_ellipse {\n \tstruct f_ellipse\t*next;\n } F_ellipse;\n \n-#define INVALID_ELLIPSE(e)\t\\\n+#define INVALID_ELLIPSE(e)\t\t\t\t\t\t\\\n \te->type < T_ELLIPSE_BY_RAD || e->type > T_CIRCLE_BY_DIA ||\t\\\n-\tCOMMON_PROPERTIES(e) || (e->direction != 1 && e->direction != 0) || \\\n-\te->radiuses.x == 0 || e->radiuses.y == 0 || \\\n+\tCOMMON_PROPERTIES(e) || (e->direction != 1 && e->direction != 0) ||  \\\n+\te->radiuses.x == 0 || e->radiuses.y == 0 ||\t\t\t\\\n \te->angle < -7. || e->angle > 7.\n \n typedef struct f_arc {\n@@ -126,12 +126,16 @@ typedef struct f_arc {\n #define CIRCARC       9\n #define CIRCULARARC   > 8\n \n-#define INVALID_ARC(a)\t\\\n+#define COINCIDENT(a, b)\t(a.x == b.x && a.y == b.y)\n+#define INVALID_ARC(a)\t\t\t\t\t\t\t\\\n \ta->type < T_OPEN_ARC || a->type > T_PIE_WEDGE_ARC ||\t\t\\\n \tCOMMON_PROPERTIES(a) || a->cap_style < 0 || a->cap_style > 2 ||\t\\\n \ta->center.x < COORD_MIN || a->center.x > COORD_MAX ||\t\t\\\n \ta->center.y < COORD_MIN || a->center.y > COORD_MAX ||\t\t\\\n-\t(a->direction != 0 && a->direction != 1)\n+\t(a->direction != 0 && a->direction != 1) ||\t\t\t\\\n+\tCOINCIDENT(a->point[0], a->point[1]) ||\t\t\t\t\\\n+\tCOINCIDENT(a->point[0], a->point[2]) ||\t\t\t\t\\\n+\tCOINCIDENT(a->point[1], a->point[2])\n \n typedef struct f_line {\n \tint\t\t\ttype;", "role": "assistant"}]}
{"messages": [{"content": "You are a security engineer fixing a CVE. You are given the vulnerability description (symptom only) and the vulnerable source window. Author the MINIMAL fix as a unified diff. Follow these rules exactly:\n1. Target ONLY the file named in the `# Vulnerable source (...)` header \u2014 do not invent or substitute file paths.\n2. Modify ONLY code visible in the shown source window.\n3. Change as few lines as possible; do not rewrite surrounding logic.\n4. Output only the unified diff with no other text.\n5. Prefer the minimal structural change: if an existing condition is missing a check, add it inline to that condition rather than inserting a new code block. If existing code is redundant or overcomplicated, replace it \u2014 do not add more code around it.\n6. Edit the most specific method or class that directly handles the vulnerable operation \u2014 not a base class, interface, or Protocol definition.", "role": "system"}, {"content": "# CVE\nCVE-2025-40928: Heap out-of-bounds read (CWE-125) in the Perl XS module JSON::XS through 4.03. The decimal number fast-path parser json_atof_scan1() in XS.xs guards against deep recursion with `if (--maxdepth <= 0) while (((U8)*s - '0') < 10) ++s;`. The sub-expression `(U8)*s - '0'` is evaluated as a signed int, so for any input byte below '0' (0x00..0x2F, including the NUL string terminator) it is negative and the `< 10` test is true. When a sufficiently long number exhausts the recursion-depth limit, the digit-skip loop walks past the end of the NUL-terminated scalar buffer, reading adjacent heap memory until it reaches a byte >= ':'. Decoding attacker-supplied JSON containing a long numeric token therefore causes an out-of-bounds read (crash, possible information disclosure).\n\n# Vulnerable source (XS.xs)\n```c\n// convert offset pointer to character index, sv must be string\nstatic STRLEN\nptr_to_index (SV *sv, char *offset)\n{\n  return SvUTF8 (sv)\n         ? utf8_distance (offset, SvPVX (sv))\n         : offset - SvPVX (sv);\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// fp hell\n\n// scan a group of digits, and a trailing exponent\nstatic void\njson_atof_scan1 (const char *s, NV *accum, int *expo, int postdp, int maxdepth)\n{\n  UV  uaccum = 0;\n  int eaccum = 0;\n\n  // if we recurse too deep, skip all remaining digits\n  // to avoid a stack overflow attack\n  if (expect_false (--maxdepth <= 0))\n    while (((U8)*s - '0') < 10)\n      ++s;\n\n  for (;;)\n    {\n      U8 dig = (U8)*s - '0';\n\n      if (expect_false (dig >= 10))\n        {\n          if (dig == (U8)((U8)'.' - (U8)'0'))\n            {\n              ++s;\n              json_atof_scan1 (s, accum, expo, 1, maxdepth);\n            }\n          else if ((dig | ' ') == 'e' - '0')\n            {\n              int exp2 = 0;\n              int neg  = 0;\n\n              ++s;\n\n              if (*s == '-')\n                {\n                  ++s;\n                  neg = 1;\n                }\n              else if (*s == '+')\n                ++s;\n\n              while ((dig = (U8)*s - '0') < 10)\n                exp2 = exp2 * 10 + *s++ - '0';\n\n              *expo += neg ? -exp2 : exp2;\n            }\n\n          break;\n        }\n\n      ++s;\n\n      uaccum = uaccum * 10 + dig;\n      ++eaccum;\n\n      // if we have too many digits, then recurse for more\n      // we actually do this for rather few digits\n      if (uaccum >= (UV_MAX - 9) / 10)\n        {\n```", "role": "user"}, {"content": "diff --git a/XS.xs b/XS.xs\n--- a/XS.xs\n+++ b/XS.xs\n@@ -253,16 +253,16 @@\n   // if we recurse too deep, skip all remaining digits\n   // to avoid a stack overflow attack\n   if (expect_false (--maxdepth <= 0))\n-    while (((U8)*s - '0') < 10)\n+    while (*s >= '0' && *s <= '9')\n       ++s;\n \n   for (;;)\n     {\n-      U8 dig = (U8)*s - '0';\n+      U8 dig = *s - '0';\n \n       if (expect_false (dig >= 10))\n         {\n-          if (dig == (U8)((U8)'.' - (U8)'0'))\n+          if (dig == (U8)('.' - '0'))\n             {\n               ++s;\n               json_atof_scan1 (s, accum, expo, 1, maxdepth);\n@@ -282,8 +282,8 @@\n               else if (*s == '+')\n                 ++s;\n \n-              while ((dig = (U8)*s - '0') < 10)\n-                exp2 = exp2 * 10 + *s++ - '0';\n+              while (*s >= '0' && *s <= '9')\n+                exp2 = exp2 * 10 + (*s++ - '0');\n \n               *expo += neg ? -exp2 : exp2;\n             }", "role": "assistant"}]}
{"messages": [{"content": "You are a security engineer fixing a CVE. You are given the vulnerability description (symptom only) and the vulnerable source window. Author the MINIMAL fix as a unified diff. Follow these rules exactly:\n1. Target ONLY the file named in the `# Vulnerable source (...)` header \u2014 do not invent or substitute file paths.\n2. Modify ONLY code visible in the shown source window.\n3. Change as few lines as possible; do not rewrite surrounding logic.\n4. Output only the unified diff with no other text.\n5. Prefer the minimal structural change: if an existing condition is missing a check, add it inline to that condition rather than inserting a new code block. If existing code is redundant or overcomplicated, replace it \u2014 do not add more code around it.\n6. Edit the most specific method or class that directly handles the vulnerable operation \u2014 not a base class, interface, or Protocol definition.", "role": "system"}, {"content": "# CVE\nCVE-2026-40347: Denial of service (CWE-407 algorithmic complexity) in the python-multipart streaming parser. An attacker who can submit a multipart/form-data body (any endpoint backed by Starlette/FastAPI form parsing) can pin CPU with a small, highly compressible payload.\n\n# Vulnerable source (python_multipart/multipart.py)\n```python\n                    lookback = boundary + b\"--\\r\\n\"\n                    self.callback(name, lookback, 0, lookbehind_len)\n                else:  # pragma: no cover (error case)\n                    self.logger.warning(\"Look-back buffer error\")\n\n                if end_i > 0:\n                    self.callback(name, data, 0, end_i)\n            # If we're getting remaining data, we have got all the data we\n            # can be certain is not a boundary, leaving only a partial boundary match.\n            if remaining:\n                self.marks[name] = end_i - length\n            else:\n                self.marks.pop(name, None)\n\n        # For each byte...\n        while i < length:\n            c = data[i]\n\n            if state == MultipartState.START:\n                # Skip leading newlines\n                if c == CR or c == LF:\n                    i += 1\n                    continue\n\n                # index is used as in index into our boundary.  Set to 0.\n                index = 0\n\n                # Move to the next state, but decrement i so that we re-process\n                # this character.\n                state = MultipartState.START_BOUNDARY\n                i -= 1\n\n            elif state == MultipartState.START_BOUNDARY:\n                # Check to ensure that the last 2 characters in our boundary\n                # are CRLF.\n                if index == len(boundary) - 2:\n                    if c == HYPHEN:\n                        # Potential empty message.\n                        state = MultipartState.END_BOUNDARY\n                    elif c != CR:\n        /* ... */\n                if index == 0 and prev_index > 0:\n                    # Overwrite our previous index.\n                    prev_index = 0\n\n                    # Re-consider the current character, since this could be\n                    # the start of the boundary itself.\n                    i -= 1\n\n            elif state == MultipartState.END_BOUNDARY:\n                if index == len(boundary) - 2 + 1:\n                    if c != HYPHEN:\n                        msg = \"Did not find - at end of boundary (%d)\" % (i,)\n                        self.logger.warning(msg)\n                        e = MultipartParseError(msg)\n                        e.offset = i\n                        raise e\n                    index += 1\n                    self.callback(\"end\")\n                    state = MultipartState.END\n\n            elif state == MultipartState.END:\n                # Don't do anything if chunk ends with CRLF.\n                if c == CR and i + 1 < length and data[i + 1] == LF:\n                    i += 2\n                    continue\n                # Skip data after the last boundary.\n                self.logger.warning(\"Skipping data after last boundary\")\n                i = length\n                break\n\n            else:  # pragma: no cover (error case)\n                # We got into a strange state somehow!  Just stop processing.\n                msg = \"Reached an unknown state %d at %d\" % (state, i)\n                self.logger.warning(msg)\n                e = MultipartParseError(msg)\n                e.offset = i\n                raise e\n\n            # Move to the next byte.\n            i += 1\n```", "role": "user"}, {"content": "diff --git a/python_multipart/multipart.py b/python_multipart/multipart.py\n--- a/python_multipart/multipart.py\n+++ b/python_multipart/multipart.py\n@@ -1106,7 +1106,11 @@ class MultipartParser(BaseParser):\n             if state == MultipartState.START:\n                 # Skip leading newlines\n                 if c == CR or c == LF:\n-                    i += 1\n+                    i = data.find(b\"-\", i)\n+                    if i == -1:\n+                        # No boundary candidate in this chunk, so ignore the content after the leading CR/LF.\n+                        i = length\n+                        break\n                     continue\n \n                 # index is used as in index into our boundary.  Set to 0.\n@@ -1414,12 +1418,8 @@ class MultipartParser(BaseParser):\n                     state = MultipartState.END\n \n             elif state == MultipartState.END:\n-                # Don't do anything if chunk ends with CRLF.\n-                if c == CR and i + 1 < length and data[i + 1] == LF:\n-                    i += 2\n-                    continue\n-                # Skip data after the last boundary.\n-                self.logger.warning(\"Skipping data after last boundary\")\n+                # Silently discard any epilogue data (RFC 2046 section 5.1.1 allows a CRLF and optional\n+                # epilogue after the closing boundary). Django and Werkzeug do the same.\n                 i = length\n                 break", "role": "assistant"}]}
{"messages": [{"content": "You are a security engineer fixing a CVE. You are given the vulnerability description (symptom only) and the vulnerable source window. Author the MINIMAL fix as a unified diff. Follow these rules exactly:\n1. Target ONLY the file named in the `# Vulnerable source (...)` header \u2014 do not invent or substitute file paths.\n2. Modify ONLY code visible in the shown source window.\n3. Change as few lines as possible; do not rewrite surrounding logic.\n4. Output only the unified diff with no other text.\n5. Prefer the minimal structural change: if an existing condition is missing a check, add it inline to that condition rather than inserting a new code block. If existing code is redundant or overcomplicated, replace it \u2014 do not add more code around it.\n6. Edit the most specific method or class that directly handles the vulnerable operation \u2014 not a base class, interface, or Protocol definition.", "role": "system"}, {"content": "# CVE\nCVE-2026-4539: ReDoS (Regular Expression Denial of Service, CWE-1333) in Pygments' Archetype Definition Language (ADL) lexer. Two regex patterns in pygments/lexers/archetype.py lacked quantifier upper bounds: (1) AtomsLexer 'archetype_id' rule used bare \\w+ inside nested alternation, enabling 2^N backtracking on crafted long identifiers; (2) AdlLexer 'GUID' rule used (\\d|[a-fA-F])+(-( \\d|[a-fA-F])+){3,}, an alternation-in-repetition pattern causing 2^N backtracking when the last segment contains a non-hex terminator. An attacker who controls input tokenized by the Pygments archetype lexer can cause indefinite CPU consumption.\n\n# Vulnerable source (pygments/lexers/archetype.py)\n```python\nfrom pygments.lexer import RegexLexer, include, bygroups, using, default\nfrom pygments.token import Text, Comment, Name, Literal, Number, String, \\\n    Punctuation, Keyword, Operator, Generic, Whitespace\n\n__all__ = ['OdinLexer', 'CadlLexer', 'AdlLexer']\n\n\nclass AtomsLexer(RegexLexer):\n    \"\"\"\n    Lexer for Values used in ADL and ODIN.\n\n    .. versionadded:: 2.1\n    \"\"\"\n\n    tokens = {\n        # ----- pseudo-states for inclusion -----\n        'whitespace': [\n            (r'\\n', Whitespace),\n            (r'\\s+', Whitespace),\n            (r'([ \\t]*)(--.*)$', bygroups(Whitespace, Comment)),\n        ],\n        'archetype_id': [\n            (r'([ \\t]*)(([a-zA-Z]\\w+(\\.[a-zA-Z]\\w+)*::)?[a-zA-Z]\\w+(-[a-zA-Z]\\w+){2}'\n             r'\\.\\w+[\\w-]*\\.v\\d+(\\.\\d+){,2}((-[a-z]+)(\\.\\d+)?)?)',\n             bygroups(Whitespace, Name.Decorator)),\n        ],\n        'date_constraints': [\n            # ISO 8601-based date/time constraints\n            (r'[Xx?YyMmDdHhSs\\d]{2,4}([:-][Xx?YyMmDdHhSs\\d]{2}){2}', Literal.Date),\n            # ISO 8601-based duration constraints + optional trailing slash\n            (r'(P[YyMmWwDd]+(T[HhMmSs]+)?|PT[HhMmSs]+)/?', Literal.Date),\n        ],\n        'ordered_values': [\n            # ISO 8601 date with optional 'T' ligature\n            (r'\\d{4}-\\d{2}-\\d{2}T?', Literal.Date),\n            # ISO 8601 time\n            (r'\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?([+-]\\d{4}|Z)?', Literal.Date),\n            # ISO 8601 duration\n            (r'P((\\d*(\\.\\d+)?[YyMmWwDd]){1,3}(T(\\d*(\\.\\d+)?[HhMmSs]){,3})?|'\n             r'T(\\d*(\\.\\d+)?[HhMmSs]){,3})', Literal.Date),\n        /* ... */\n            (r'^([ \\t]*|[ \\t]+.*)\\n', using(OdinLexer)),\n            (r'^([^\"]*\")(>[ \\t]*\\n)', bygroups(String, Punctuation)),\n            # template overlay delimiter\n            (r'^----------*\\n', Text, '#pop'),\n            (r'^.*\\n', String),\n            default('#pop'),\n        ],\n        'cadl_section': [\n            (r'^([ \\t]*|[ \\t]+.*)\\n', using(CadlLexer)),\n            default('#pop'),\n        ],\n        'rules_section': [\n            (r'^[ \\t]+.*\\n', using(CadlLexer)),\n            default('#pop'),\n        ],\n        'metadata': [\n            (r'\\)', Punctuation, '#pop'),\n            (r';', Punctuation),\n            (r'([Tt]rue|[Ff]alse)', Literal),\n            # numbers and version ids\n            (r'\\d+(\\.\\d+)*', Literal),\n            # Guids\n            (r'(\\d|[a-fA-F])+(-(\\d|[a-fA-F])+){3,}', Literal),\n            (r'\\w+', Name.Class),\n            (r'\"', String, 'string'),\n            (r'=', Operator),\n            (r'[ \\t]+', Whitespace),\n            default('#pop'),\n        ],\n        'root': [\n            (r'^(archetype|template_overlay|operational_template|template|'\n             r'speciali[sz]e)', Generic.Heading),\n            (r'^(language|description|ontology|terminology|annotations|'\n             r'component_terminologies|revision_history)[ \\t]*\\n',\n             Generic.Heading, 'odin_section'),\n            (r'^(definition)[ \\t]*\\n', Generic.Heading, 'cadl_section'),\n            (r'^(rules)[ \\t]*\\n', Generic.Heading, 'rules_section'),\n            include('archetype_id'),\n            (r'([ \\t]*)(\\()', bygroups(Whitespace, Punctuation), 'metadata'),\n            include('whitespace'),\n```", "role": "user"}, {"content": "diff --git a/pygments/lexers/archetype.py b/pygments/lexers/archetype.py\n--- a/pygments/lexers/archetype.py\n+++ b/pygments/lexers/archetype.py\n@@ -35,8 +35,8 @@ class AtomsLexer(RegexLexer):\n             (r'([ \\t]*)(--.*)$', bygroups(Whitespace, Comment)),\n         ],\n         'archetype_id': [\n-            (r'([ \\t]*)(([a-zA-Z]\\w+(\\.[a-zA-Z]\\w+)*::)?[a-zA-Z]\\w+(-[a-zA-Z]\\w+){2}'\n-             r'\\.\\w+[\\w-]*\\.v\\d+(\\.\\d+){,2}((-[a-z]+)(\\.\\d+)?)?)',\n+            (r'([ \\t]*)(([a-zA-Z]\\w{1,100}(\\.[a-zA-Z]\\w{1,100})*::)?[a-zA-Z]\\w{1,100}(-[a-zA-Z]\\w{1,100}){2}'\n+             r'\\.\\w{1,100}[\\w-]*\\.v\\d+(\\.\\d+){,2}((-[a-z]+)(\\.\\d+)?)?)',\n              bygroups(Whitespace, Name.Decorator)),\n         ],\n         'date_constraints': [\n@@ -293,7 +293,7 @@ class AdlLexer(AtomsLexer):\n             # numbers and version ids\n             (r'\\d+(\\.\\d+)*', Literal),\n             # Guids\n-            (r'(\\d|[a-fA-F])+(-(\\d|[a-fA-F])+){3,}', Literal),\n+            (r'[0-9a-fA-F]{1,36}(-[0-9a-fA-F]{1,36}){3,}', Literal),\n             (r'\\w+', Name.Class),\n             (r'\"', String, 'string'),\n             (r'=', Operator),", "role": "assistant"}]}