[PR #3954] [MERGED] Harden custom agent file imports #6175

Closed
opened 2026-10-23 04:07:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3954
Author: @SpicyMarinara
Created: 7/22/2026
Status: ✅ Merged
Merged: 7/22/2026
Merged by: @SpicyMarinara

Base: staging ← Head: agent/harden-agent-imports


📝 Commits (3)

  • a4cdc78 Harden custom agent file imports
  • 0168f8a fix: count only bundled agent functions
  • 6e2da25 Merge remote-tracking branch 'origin/staging' into agent/harden-agent-imports

📊 Changes

8 files changed (+296 additions, -144 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/agents/custom-agents.md (+4 -2)
📝 docs/extending/custom-tools.md (+1 -1)
📝 package.json (+2 -1)
📝 packages/client/src/components/agents/AgentEditor.tsx (+14 -28)
📝 packages/client/src/components/panels/AgentsPanel.tsx (+26 -96)
📝 packages/client/src/lib/agent-transfer.ts (+107 -16)
➕ scripts/regressions/agent-import-security.regression.ts (+141 -0)

📄 Description

Linked issue

Closes #3953

Why this change

  • Custom agent ZIP/JSON imports could preserve enabledTools and automatically create bundled custom functions. An activated third-party agent could then call an attacker-controlled webhook and send hidden conversation context.
  • A crafted import could also reuse an official Agent type and overwrite that curated Agent's active prompt and configuration.
  • Official packages from the curated Pasta-Devs/Marinara-Agents catalog are a separate trusted-code path and remain unaffected.

What changed

  • Agent exports now contain agent prompt/configuration files only and never bundle custom-function definitions.
  • Agent imports detect and skip legacy bundled functions, report the skipped count, and direct users to review trusted functions separately in Function Calls.
  • Imported settings lose all requested tool grants, writable-tool targets, secrets, and custom-repository provenance.
  • Every file-imported agent receives a fresh custom identity so it cannot overwrite an official or already-active Agent configuration.
  • Added focused regression coverage and updated the custom-agent/custom-tool documentation and changelog.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Automated evidence produced during implementation:

  • pnpm regression:agent-import-security passed.
  • pnpm check passed after the final code changes. ESLint reported one pre-existing warning in HomeProfessorMariChat.tsx, with zero errors.

Manual verification notes

  • No real-browser import was performed in this environment.
  • Manually verify that importing a legacy agent ZIP with bundled functions imports the agent, skips the functions, shows the safety notice, and leaves the imported agent with no selected tools.
  • Manually verify that an import claiming the spotify type creates a separate custom agent without changing Music DJ.
  • Manually verify that official catalog Agents still install and run normally.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

Updated docs/agents/custom-agents.md, docs/extending/custom-tools.md, and CHANGELOG.md. No version bump.

UI evidence (if applicable)

No screenshot captured; the only visible change is inline import-status copy when bundled functions are skipped.

Summary by CodeRabbit

  • Security

    • Improved agent importing to prevent imported files from granting tools, installing bundled functions, or overwriting built-in agents.
    • Imported agents receive a unique identity and require explicit tool selection.
  • Documentation

    • Clarified that agent exports exclude custom tools and that tools must be imported and attached separately.
    • Documented that conflicting or built-in tool names are skipped during import.
  • Bug Fixes

    • Added clearer import notifications when bundled functions are skipped.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3954 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/22/2026 **Status:** ✅ Merged **Merged:** 7/22/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/harden-agent-imports` --- ### 📝 Commits (3) - [`a4cdc78`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a4cdc786d693e4cd4165cce92e7ebbf4ee4407ac) Harden custom agent file imports - [`0168f8a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0168f8a6d3088feb7e8ec563a193dc66b407a5b1) fix: count only bundled agent functions - [`6e2da25`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6e2da2587bf4cd821f45efb5feb8786f5f1286ef) Merge remote-tracking branch 'origin/staging' into agent/harden-agent-imports ### 📊 Changes **8 files changed** (+296 additions, -144 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/agents/custom-agents.md` (+4 -2) 📝 `docs/extending/custom-tools.md` (+1 -1) 📝 `package.json` (+2 -1) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+14 -28) 📝 `packages/client/src/components/panels/AgentsPanel.tsx` (+26 -96) 📝 `packages/client/src/lib/agent-transfer.ts` (+107 -16) ➕ `scripts/regressions/agent-import-security.regression.ts` (+141 -0) </details> ### 📄 Description ## Linked issue Closes #3953 ## Why this change - Custom agent ZIP/JSON imports could preserve `enabledTools` and automatically create bundled custom functions. An activated third-party agent could then call an attacker-controlled webhook and send hidden conversation context. - A crafted import could also reuse an official Agent type and overwrite that curated Agent's active prompt and configuration. - Official packages from the curated `Pasta-Devs/Marinara-Agents` catalog are a separate trusted-code path and remain unaffected. ## What changed - Agent exports now contain agent prompt/configuration files only and never bundle custom-function definitions. - Agent imports detect and skip legacy bundled functions, report the skipped count, and direct users to review trusted functions separately in Function Calls. - Imported settings lose all requested tool grants, writable-tool targets, secrets, and custom-repository provenance. - Every file-imported agent receives a fresh custom identity so it cannot overwrite an official or already-active Agent configuration. - Added focused regression coverage and updated the custom-agent/custom-tool documentation and changelog. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Automated evidence produced during implementation: - `pnpm regression:agent-import-security` passed. - `pnpm check` passed after the final code changes. ESLint reported one pre-existing warning in `HomeProfessorMariChat.tsx`, with zero errors. ### Manual verification notes - No real-browser import was performed in this environment. - Manually verify that importing a legacy agent ZIP with bundled functions imports the agent, skips the functions, shows the safety notice, and leaves the imported agent with no selected tools. - Manually verify that an import claiming the `spotify` type creates a separate custom agent without changing Music DJ. - Manually verify that official catalog Agents still install and run normally. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) Updated `docs/agents/custom-agents.md`, `docs/extending/custom-tools.md`, and `CHANGELOG.md`. No version bump. ## UI evidence (if applicable) No screenshot captured; the only visible change is inline import-status copy when bundled functions are skipped. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Security** * Improved agent importing to prevent imported files from granting tools, installing bundled functions, or overwriting built-in agents. * Imported agents receive a unique identity and require explicit tool selection. * **Documentation** * Clarified that agent exports exclude custom tools and that tools must be imported and attached separately. * Documented that conflicting or built-in tool names are skipped during import. * **Bug Fixes** * Added clearer import notifications when bundled functions are skipped. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:07:48 +07:00
Sign in to join this conversation.
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
Pasta-Devs/Marinara-Engine#6175
No description provided.