fix(backend): Excel formula-injection (#1244) + chat read off event loop (#1245) #1307

Merged
bot-backend merged 1 commit from fix/excel-injection-chat-threadpool-1244-1245 into main 2026-06-13 13:19:44 +00:00
Collaborator

Summary

Два Fable5 P3 «uncertain» бага — оба верифицированы REAL и пофикшены.

#1244 Excel formula/DDE-injection (security)

Внешние/скрейпинг-строки (comm_name из DOM.РФ, headline/usp_text) с ведущим = + - @ \t \r писались как есть → openpyxl сохранял формулами (data_type='f'), исполнялись при открытии. _sanitize_formula префиксует апострофом (OWASP CSV-injection). Числа/даты/bool не трогаются. Подтверждено на openpyxl 3.1.5; все sink-paths audited (code-reviewer ).

#1245 chat async sync-read (concurrency)

async ask() вызывал sync get_report_for_chat (sync SQLAlchemy, крупный JSONB §22) — блокировал event loop. Обёрнуто в run_in_threadpool (как LLM-ветка).

Test plan

  • 42 passed (6 injection + 1 threadpool + регрессия), negative-controls fail на pre-fix коде
  • ruff clean, code-reviewer APPROVE (security-полнота эмпирически)

Closes #1244
Closes #1245

## Summary Два Fable5 P3 «uncertain» бага — оба верифицированы REAL и пофикшены. ### #1244 Excel formula/DDE-injection (security) Внешние/скрейпинг-строки (comm_name из DOM.РФ, headline/usp_text) с ведущим `= + - @ \t \r` писались как есть → openpyxl сохранял формулами (data_type='f'), исполнялись при открытии. `_sanitize_formula` префиксует апострофом (OWASP CSV-injection). Числа/даты/bool не трогаются. Подтверждено на openpyxl 3.1.5; все sink-paths audited (code-reviewer ✅). ### #1245 chat async sync-read (concurrency) `async ask()` вызывал sync `get_report_for_chat` (sync SQLAlchemy, крупный JSONB §22) — блокировал event loop. Обёрнуто в `run_in_threadpool` (как LLM-ветка). ## Test plan - [x] 42 passed (6 injection + 1 threadpool + регрессия), negative-controls fail на pre-fix коде - [x] ruff clean, code-reviewer ✅ APPROVE (security-полнота эмпирически) Closes #1244 Closes #1245
bot-backend added 1 commit 2026-06-13 13:10:53 +00:00
fix(backend): экранировать Excel formula-injection (#1244) + увести chat-чтение с event loop (#1245)
Some checks failed
CI / changes (push) Successful in 6s
CI / frontend-tests (push) Has been skipped
CI / changes (pull_request) Successful in 7s
CI / frontend-tests (pull_request) Has been skipped
CI / backend-tests (push) Successful in 6m38s
CI / backend-tests (pull_request) Successful in 6m37s
Deploy / build-backend (push) Blocked by required conditions
Deploy / build-worker (push) Blocked by required conditions
Deploy / build-frontend (push) Blocked by required conditions
Deploy / deploy (push) Blocked by required conditions
Deploy / changes (push) Has been cancelled
3cf9fad683
#1244 (security): внешние/скрейпинг-строки (comm_name из DOM.РФ, headline/usp_text)
с ведущим = + - @ \t \r писались как есть → openpyxl сохранял как формулы
(data_type='f'), исполнялись при открытии в Excel/LibreOffice. _sanitize_formula
префиксует такие строки апострофом (OWASP CSV-injection escape); числа/даты/bool
не трогаются. _write_kv labels тоже санитизируются. Подтверждено на openpyxl 3.1.5.

#1245 (concurrency): async ask() вызывал sync get_report_for_chat() (sync SQLAlchemy
тянет крупный JSONB §22-отчёт) напрямую — блокировал event loop, в отличие от
LLM-ветки (run_in_threadpool). Обёрнуто в run_in_threadpool.

Closes #1244
Closes #1245
bot-backend merged commit 3cf9fad683 into main 2026-06-13 13:19:44 +00:00
bot-backend deleted branch fix/excel-injection-chat-threadpool-1244-1245 2026-06-13 13:19:44 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1307
No description provided.