Skip to content

fix: harden shared agent source permissions - #2417

Merged
lyingbug merged 2 commits into
Tencent:mainfrom
lyingbug:agent/harden-shared-agent-permissions
Jul 30, 2026
Merged

fix: harden shared agent source permissions#2417
lyingbug merged 2 commits into
Tencent:mainfrom
lyingbug:agent/harden-shared-agent-permissions

Conversation

@lyingbug

Copy link
Copy Markdown
Collaborator

Summary

  • validate the exact shared-agent source space through organization membership, share relation, and source agent before using it as a runtime selector
  • resolve shared-agent web-search readiness, model/KB/MCP resources, and attachment processing dependencies from the authorized source space
  • propagate the source selector through chat, temporary attachments, knowledge APIs, mentions, and frontend cache keys
  • enforce the read-only share contract inside the agent engine by filtering source-space Wiki mutation tools
  • add regression coverage for exact-source resolution, source web-search configuration, and shared-agent write-tool filtering

Root cause

Shared-agent execution already switched several backend runtime resources to the source space, but adjacent paths used inconsistent authority:

  • the frontend checked the receiving space's web-search providers, so a valid source-space provider appeared unavailable
  • agent IDs alone were ambiguous when multiple spaces shared same-ID built-in agents
  • the HTTP knowledge permission boundary did not prevent the agent engine from invoking source-space Wiki write tools
  • temporary documents mixed attachment ownership with the space used to resolve parser, ASR, and VLM resources

Impact

Recipients can use the capabilities intentionally configured on a shared agent, including source-space web search and scoped knowledge resources, without receiving provider credentials. Shared-agent runs remain read-only for source-space Wiki content, and a client-supplied source selector cannot grant access without a matching verified share relation.

Validation

  • GOCACHE=/tmp/weknora-gocache-shared-agent-publish go test ./internal/application/repository ./internal/application/service ./internal/handler ./internal/handler/session ./internal/middleware ./internal/router ./internal/types ./internal/container
  • npx tsx --test src/utils/agentWebSearch.test.mjs src/components/Input-field.agent-switch.test.mjs (7/7)
  • npm run build-only -- --mode development
  • git diff --cached --check

lyingbug added 2 commits July 30, 2026 12:10
Reject invalid agent_source_tenant_id instead of silently falling back, fix a resolveAgent nil panic when a shared selector fails, and add regression tests for wiki write-tool filtering and agent resolution.
@lyingbug
lyingbug marked this pull request as ready for review July 30, 2026 04:28
@lyingbug
lyingbug merged commit cc846d8 into Tencent:main Jul 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant