Commit Graph

1980 Commits

Author SHA1 Message Date
nopoz d62eba42ce fix(security): prevent ReDoS in XML and args tool-call parsers (#4941)
* fix(security): prevent ReDoS in XML and args tool-call parsers

Four py/polynomial-redos sinks in tool_parsing.py ran lazy/greedy regexes over
untrusted model output (tool-call markup is attacker-influenced via prompt
injection). When the closing delimiter was absent, each rescanned to
end-of-string from every opener -> O(n^2):

  - args => { ... } in _parse_tool_call_block: greedy \{([\s\S]*)\} restarted
    from every `args:{` opener. Now finds the opener once and takes through the
    last `}` (rfind) — equivalent capture, O(n).
  - _XML_INVOKE_RE: lazy <invoke ...>([\s\S]*?)</invoke>. Now _iter_xml_invoke
    pairs each opener with the first reachable </invoke> and stops when none is.
  - _XML_DIRECT_TOOL_RE and the <tag>([\s\S]*?)</\1> param scan in
    _parse_tool_code_block: lazy backreference patterns. Now _iter_backref_blocks
    pairs each opener with the nearest matching closer and memoizes tag names
    with no remaining closer, so an opener flood stays O(n).

All four are output-equivalent to the originals on well-formed tool-call markup;
the lazy patterns remain defined (still re-exported via agent_tools) but no
longer drive a finditer over untrusted text. Adds tests/test_redos_xml_tool_parsers.py
pinning correctness and bounding the opener-flood inputs (old paths took 4-15s).

* fix(security): harden invoke-parameter and distinct-name tag scans

Forward-only the two residual ReDoS paths in the XML/tool parsers that the
outer-delimiter fix left quadratic:

- _parse_xml_invoke parsed <parameter> with _XML_PARAM_RE.finditer, so a
  closed <invoke> body full of unclosed <parameter> openers rescanned the
  body from every opener (O(n^2), ~11s at 8k openers). Now scans forward-only
  via _iter_named_blocks, factored out of _iter_xml_invoke.
- _iter_backref_blocks only memoized repeated missing tag names; a flood of
  distinct unclosed names searched the suffix once per name (O(n^2)). It now
  indexes every closer by name in one linear pass and binary-searches per
  opener (O(n log n)). Covers the direct and tool_code backref scans.

Output-equivalent to the prior scanners (200k randomized trials match the
memoized version for both the direct ci=True and tool_code ci=False configs).
Adds regressions for the closed-invoke parameter flood and the distinct-name
floods (45k openers now run in ~0.05s, were 5-6s).
2026-06-27 15:42:55 -07:00
pewdiepie-archdaemon f938b89a9d Set cookbook GPU buttons to 30px 2026-06-27 22:38:02 +00:00
pewdiepie-archdaemon a7c25c1997 Toggle manual hardware edit button 2026-06-27 22:35:50 +00:00
pewdiepie-archdaemon 3b5d8002a3 Simplify cookbook scan use cases 2026-06-27 22:30:54 +00:00
pewdiepie-archdaemon 27ce89a623 Adjust cookbook serve control spacing 2026-06-27 22:29:56 +00:00
pewdiepie-archdaemon 6f10e07ef5 Clarify cookbook conda env support 2026-06-27 22:27:55 +00:00
pewdiepie-archdaemon b4b3a1e18c Move serve memory fields left again 2026-06-27 22:25:25 +00:00
pewdiepie-archdaemon 1aa3af750f Adjust serve preset and memory field offsets 2026-06-27 22:15:07 +00:00
pewdiepie-archdaemon 20f5fa905d Align runtime note with serve presets 2026-06-27 22:13:20 +00:00
pewdiepie-archdaemon d33e3fd6f5 Move core serve memory fields further left 2026-06-27 22:11:18 +00:00
pewdiepie-archdaemon 59c2cbe405 Move core serve memory fields farther left 2026-06-27 22:10:15 +00:00
pewdiepie-archdaemon 80b287ee56 Move core serve memory fields left 2026-06-27 22:09:14 +00:00
pewdiepie-archdaemon 97f8b3bcd3 Add icons to cookbook engine filter 2026-06-27 22:01:23 +00:00
pewdiepie-archdaemon 6d31cfcf4c Move vllm block size left again 2026-06-27 21:55:53 +00:00
pewdiepie-archdaemon 91a94cf00a Move vllm block size left 2026-06-27 21:54:18 +00:00
pewdiepie-archdaemon 7d3f8d6527 Move vllm attention farther right 2026-06-27 21:49:35 +00:00
pewdiepie-archdaemon 3abe4f75b7 Lower CPU llama memory row 2026-06-27 21:48:19 +00:00
pewdiepie-archdaemon 60e13cf8db Adjust CPU llama row and VRAM readout 2026-06-27 21:45:04 +00:00
pewdiepie-archdaemon c288fb9f4a Match launch command hover surface 2026-06-27 21:42:06 +00:00
pewdiepie-archdaemon d46b08d8c6 Darken cookbook launch command 2026-06-27 21:39:26 +00:00
pewdiepie-archdaemon 4db0feed10 Nudge vllm attention field right 2026-06-27 21:38:34 +00:00
pewdiepie-archdaemon 46e01b49f4 Increase llama mode toggle height 2026-06-27 21:37:11 +00:00
pewdiepie-archdaemon eb51935074 Lower stabilized llama advanced block 2026-06-27 21:34:37 +00:00
pewdiepie-archdaemon c0ee638fcc Stabilize llama advanced row spacing 2026-06-27 21:33:13 +00:00
pewdiepie-archdaemon edf06a8048 Tighten llama memory row gap again 2026-06-27 21:31:00 +00:00
pewdiepie-archdaemon 5bc3a69251 Tighten llama memory row gap 2026-06-27 21:29:19 +00:00
pewdiepie-archdaemon a193e6b815 Tighten first llama advanced row gap 2026-06-27 21:28:14 +00:00
pewdiepie-archdaemon 7fe55a2942 Fine tune llama advanced spacing 2026-06-27 21:25:37 +00:00
Solanki Sumit 745dc8d775 fix(health): report unhealthy memory vector store as degraded
Keep an unhealthy MemoryVectorStore instance available for health reporting instead of discarding it as disabled. This lets health checks report a degraded/down vector-store state while preserving focused regression coverage for initializer behavior.
2026-06-27 22:25:13 +01:00
pewdiepie-archdaemon 0c53672ae9 Adjust llama advanced top spacing 2026-06-27 21:23:39 +00:00
pewdiepie-archdaemon 1eebfb862e Lower cookbook serve top row 2026-06-27 21:20:27 +00:00
pewdiepie-archdaemon 0ee2e0069f Tint Ollama engine icon 2026-06-27 21:18:15 +00:00
pewdiepie-archdaemon c157553fb7 Refine llama advanced row spacing 2026-06-27 21:17:24 +00:00
pewdiepie-archdaemon cbc5d6c341 Simplify llama MTP token input 2026-06-27 21:14:21 +00:00
pewdiepie-archdaemon a0f6f27ff7 Nudge llama advanced rows right 2026-06-27 21:13:20 +00:00
pewdiepie-archdaemon 4ced5da463 Tighten llama advanced vertical spacing 2026-06-27 21:12:12 +00:00
pewdiepie-archdaemon 3b7e6bb3fd Nudge vllm attention field 2026-06-27 21:11:18 +00:00
pewdiepie-archdaemon 277879beec Tighten llama advanced rows further 2026-06-27 21:10:38 +00:00
pewdiepie-archdaemon d45543abaa Tighten llama advanced rows 2026-06-27 21:07:57 +00:00
pewdiepie-archdaemon 448ed1b4e9 Limit cookbook spacing change to advanced tab 2026-06-27 21:05:07 +00:00
pewdiepie-archdaemon 912a4e2ba7 Color cookbook context fit notes 2026-06-27 21:02:10 +00:00
pewdiepie-archdaemon 424ebfa5cb Raise unified llama context estimate 2026-06-27 20:56:57 +00:00
pewdiepie-archdaemon f177d38c62 Clamp unified llama context estimate 2026-06-27 20:52:31 +00:00
Ricardo 0fa3f4ca91 fix(email): don't probe IMAP for send-only (SMTP-only) accounts (#4830)
An account configured with SMTP only (no imap_host) has no inbox, but the
inbox list path still called _imap_connect, which handed an empty host to
imaplib. imaplib.IMAP4("", 993) silently dials localhost:993 and fails with
"[Errno 111] Connection refused", so the email panel's poll logged a
"Failed to list emails" ERROR every ~60s and surfaced a scary error in the UI.

_imap_connect now fails fast with a typed EmailNotConfiguredError (subclass of
RuntimeError, so existing broad handlers keep working) when no imap_host is set,
and the inbox list returns an empty result for that case instead of an error.
SMTP send is unaffected.
2026-06-27 21:52:26 +01:00
pewdiepie-archdaemon 6d78f6f7f7 Add cookbook empty scan buttons 2026-06-27 20:48:24 +00:00
pewdiepie-archdaemon efa4370a48 Rename email auto translate task 2026-06-27 20:46:45 +00:00
Alexandre Teixeira 6dcd2dd436 test: split provider detection tests (#4933) 2026-06-27 21:46:33 +01:00
pewdiepie-archdaemon e9446f41c0 Register email auto translate task 2026-06-27 20:43:56 +00:00
Alexandre Teixeira f1ca973f98 test: split llm-core temperature tests (#4935) 2026-06-27 22:02:41 +02:00
Afonso Coutinho e195edf306 fix: tool results misthreaded to the wrong tool_call_id when a native call fails to convert (#1917)
* fix: tool results misthreaded when a native call fails to convert

* Unpack the third converted_calls return from _resolve_tool_blocks in the fenced-example tests
2026-06-27 19:31:17 +01:00