You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
security(kb): the knowledge search and RAG routes filter results by the caller's access #16665
Found during the #16667 inventory, and in scope here: api/knowledge_mcp.py:466-469 passes filters=request.filters or RESEARCH_QUARANTINE_FILTER, so any filter the caller supplies replaces the research quarantine, and quarantined research facts come back through MCP search. When this route gets its ownership filter, the quarantine must be combined with any caller filter, never replaced by it.
Progress from PR #16716 (fix at ca12fca46, review pending merge) — partial, not closing.
Covers 3 of the routes/files listed in this issue's Problem section:
api/ai_stack_integration.py: chat and rag_query (:105/:195 region) now filter KB context through filter_search_results_by_permission with the caller's own scope — previously had no filtering at all, gated only by check_admin_permission.
api/knowledge_ai_stack.py (:264/:315 region — search/rag_search): the is_admin= bypass keyword removed from the existing filter_search_results_by_permission calls, so an admin caller is filtered identically to any other caller for these RAG-synthesis-bound reads. Same treatment for advanced_search in api/knowledge_rag.py.
knowledge_search in ai_stack_integration.py is confirmed correct as an explicit-admin-read route (per the 2026-09-13 owner decision above) and was left untouched.
Test coverage added per this issue's AC2 for the 3 routes touched: a private fact belonging to user A is not returned to user B or to an admin in the RAG/chat context (verified as a genuine negative control — reverting the fix locally makes these tests fail with the private fact actually present).
Not covered by #16716, still open per this issue's list: api/knowledge_search.py, api/knowledge_search_aggregator.py (partially covered by a separate PR per earlier review — worth checking before assuming it's fully open), api/knowledge_suggestions.py, api/knowledge_grounding.py, api/knowledge_mcp.py, api/graph_rag.py, api/kb_librarian.py, api/knowledge_graph_routes.py, and the remaining ai_stack_integration.py/knowledge_rag.py line references (:269, :625) not part of this PR's diff.
Status check against origin/main (1edec3064c): 0 of 3. Five of the eleven named files now filter; six show none at the route or its named service
#16716 (merged 2026-09-19) covered ai_stack_integration.py and knowledge_ai_stack.py; later commits added filtering in more files. Counted calls to filter_search_results_by_permission / check_access per file named in this issue:
its named service knowledge/suggestions.py also has 0
knowledge_grounding.py
0
knowledge_mcp.py
0
graph_rag.py
0
services/graph_rag_service.py also has 0
kb_librarian.py
0
agents/kb_librarian_agent.py also has 0
knowledge_graph_routes.py
0
Scope of this check, stated so it is not over-read: I counted calls to those helpers in each route file and, where the issue names one, its service module. I did not trace every call chain to the bottom. A filter applied deeper (e.g. inside a shared search primitive) would not show up here, so the six zeros mean "no enforcement found at the route or its named service", not "proven unenforced". Criterion 2 (a per-route A/B/admin test) is the check that would settle each one. None of the three criteria can be ticked: criterion 1 is not met for six files, criterion 2 has no per-route tests for them, and criterion 3 was not checked here.
Sighting (2026-10-09 graph-retrieval sweep): autobot-backend/api/graph_rag.py:172 — the /graph-rag search handler takes current_user for authentication only and never filters results by caller access; services/graph_rag_service.py receives no user. Graph-expanded items here are unfiltered, while api/knowledge_search_aggregator.py:77-145 already applies "a relation is not an access grant". Witness only — the fix stays in this issue. Also a precondition for #18144 (graph view in chat).
Activity
mrveiss commentedon Sep 13, 2026
Found during the #16667 inventory, and in scope here:
api/knowledge_mcp.py:466-469passesfilters=request.filters or RESEARCH_QUARANTINE_FILTER, so any filter the caller supplies replaces the research quarantine, and quarantined research facts come back through MCP search. When this route gets its ownership filter, the quarantine must be combined with any caller filter, never replaced by it.security(kb): the multi-source search/context/graph routes filter res…
fix(kb): correct the response-schema import path in the two extracted…
fix(kb): correct the analytics import path, and decode JSON-encoded f…
fix(kb): restore 2 allowlist entries the guard's single-hop scan can'…
fix(kb): restore the category-counts allowlist entry the guard's scan…
fix(kb): configure rag_integration_api_test.py's ownership_manager mo…
fix(kb): configure rag_integration_api_test.py's ownership_manager mo…
fix(kb): configure rag_integration_api_test.py's ownership_manager mo…
github-actions commentedon Sep 14, 2026
PR #16691 (merged to
main) references this issue with a close keyword.If this issue is fully resolved, close it manually. If work remains, no action is needed.
fix(security): remove admin read bypass from KB-fed chat/RAG synthesis (
fix(kb): move the knowledge_rag_loop import to the top of knowledge_r…
mrveiss commentedon Sep 18, 2026
Progress from PR #16716 (fix at
ca12fca46, review pending merge) — partial, not closing.Covers 3 of the routes/files listed in this issue's Problem section:
api/ai_stack_integration.py:chatandrag_query(:105/:195region) now filter KB context throughfilter_search_results_by_permissionwith the caller's own scope — previously had no filtering at all, gated only bycheck_admin_permission.api/knowledge_ai_stack.py(:264/:315region —search/rag_search): theis_admin=bypass keyword removed from the existingfilter_search_results_by_permissioncalls, so an admin caller is filtered identically to any other caller for these RAG-synthesis-bound reads. Same treatment foradvanced_searchinapi/knowledge_rag.py.knowledge_searchinai_stack_integration.pyis confirmed correct as an explicit-admin-read route (per the 2026-09-13 owner decision above) and was left untouched.Test coverage added per this issue's AC2 for the 3 routes touched: a private fact belonging to user A is not returned to user B or to an admin in the RAG/chat context (verified as a genuine negative control — reverting the fix locally makes these tests fail with the private fact actually present).
Not covered by #16716, still open per this issue's list:
api/knowledge_search.py,api/knowledge_search_aggregator.py(partially covered by a separate PR per earlier review — worth checking before assuming it's fully open),api/knowledge_suggestions.py,api/knowledge_grounding.py,api/knowledge_mcp.py,api/graph_rag.py,api/kb_librarian.py,api/knowledge_graph_routes.py, and the remainingai_stack_integration.py/knowledge_rag.pyline references (:269,:625) not part of this PR's diff.fix(backend): consolidate #16908 duplicate-route dedupe into #16716's…
Merge pull request #16716 from mrveiss/issue-16665-kb-ai-rag-visibility
mrveiss commentedon Oct 3, 2026
Status check against
origin/main(1edec3064c): 0 of 3. Five of the eleven named files now filter; six show none at the route or its named service#16716 (merged 2026-09-19) covered
ai_stack_integration.pyandknowledge_ai_stack.py; later commits added filtering in more files. Counted calls tofilter_search_results_by_permission/check_accessper file named in this issue:autobot-backend/api/…knowledge_search.pyknowledge_search_aggregator.pyknowledge_ai_stack.pyai_stack_integration.pyknowledge_rag.pyknowledge_suggestions.pyknowledge/suggestions.pyalso has 0knowledge_grounding.pyknowledge_mcp.pygraph_rag.pyservices/graph_rag_service.pyalso has 0kb_librarian.pyagents/kb_librarian_agent.pyalso has 0knowledge_graph_routes.pyScope of this check, stated so it is not over-read: I counted calls to those helpers in each route file and, where the issue names one, its service module. I did not trace every call chain to the bottom. A filter applied deeper (e.g. inside a shared search primitive) would not show up here, so the six zeros mean "no enforcement found at the route or its named service", not "proven unenforced". Criterion 2 (a per-route A/B/admin test) is the check that would settle each one. None of the three criteria can be ticked: criterion 1 is not met for six files, criterion 2 has no per-route tests for them, and criterion 3 was not checked here.
mrveiss commentedon Oct 9, 2026
Sighting (2026-10-09 graph-retrieval sweep):
autobot-backend/api/graph_rag.py:172— the/graph-ragsearch handler takescurrent_userfor authentication only and never filters results by caller access;services/graph_rag_service.pyreceives no user. Graph-expanded items here are unfiltered, whileapi/knowledge_search_aggregator.py:77-145already applies "a relation is not an access grant". Witness only — the fix stays in this issue. Also a precondition for #18144 (graph view in chat).