[security] fix(prompts,installer): require explicit prompt opt-in and disable plugin lifecycle scripts#1546
Open
Hinotoi-agent wants to merge 3 commits intovolcengine:mainfrom
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens two execution-capable trust boundaries in OpenViking.
prompts.enable_custom_templatesPromptManager.render()Security issues covered
prompts.templates_dirat writable storage-backed pathsPromptManager.render()npm installran lifecycle hooksBefore this PR
prompts.templates_dirandOPENVIKING_PROMPT_TEMPLATES_DIRwere honored automatically once present.PromptManager.render()used raw Jinja rendering, so custom prompt content was treated as executable template code.npm installinside plugin directories without disabling lifecycle scripts.After this PR
prompts.enable_custom_templates: truebefore config- or environment-based custom prompt directories are used.Explicit operator choice
Secure default configuration:
{ "prompts": { "enable_custom_templates": false } }Explicit opt-in configuration:
{ "prompts": { "enable_custom_templates": true, "templates_dir": "/path/to/custom-prompts" } }Disabled state:
prompts.templates_diris ignoredOPENVIKING_PROMPT_TEMPLATES_DIRis ignoredEnabled state:
Why this matters
These issues cross a content-to-execution boundary.
In the prompt path, writable template content could move from configuration/storage into executable Jinja at render time. In the installer path, plugin package metadata could move from plugin content into code execution through npm lifecycle hooks. Both should require an explicit trust boundary instead of happening implicitly.
Attack flow
Affected code
openviking/prompts/manager.py,openviking_cli/utils/config/prompts_config.py,tests/test_prompt_manager.py,tests/misc/test_prompt_manager_security.py,docs/en/guides/10-prompt-guide.md,docs/zh/guides/10-prompt-guide.mdexamples/openclaw-plugin/setup-helper/install.js,examples/openclaw-plugin/install.sh,bot/scripts/install_local_openclaw_plugin.shRoot cause
Issue 1: Config/env-driven custom prompt template loading by default
Issue 2: Unsandboxed custom prompt template rendering
Issue 3: Plugin installer lifecycle-script execution
npm installdirectly inside attacker-controlled plugin directories.CVSS assessment
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:HCVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:HCVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:HRationale:
Safe reproduction steps
1. Prompt custom-template execution
prompts.templates_dir.PromptManager.render()for that template.prompts.enable_custom_templates: true, and unsafe Jinja attribute traversal is blocked even when opt-in is enabled.2. OpenClaw plugin installer lifecycle execution
package.jsoncontaining a safepostinstallpayload that only writes a harmless marker file.npm installin the plugin staging/deploy directory.npm install --ignore-scripts, so the marker file is not created.Expected vulnerable behavior
Changes in this PR
prompts.enable_custom_templateswith a secure default offalsePromptManagerignore config- and environment-driven external template directories unless that setting is enabledPromptManagerwith a sandboxed Jinja environment--ignore-scriptsto the OpenClaw plugin installer and local install helper npm install flowsFiles changed
openviking_cli/utils/config/prompts_config.pyenable_custom_templateswith a default-secure opt-in modelopenviking/prompts/manager.pytests/test_prompt_manager.py,tests/misc/test_prompt_manager_security.pydocs/en/guides/10-prompt-guide.md,docs/zh/guides/10-prompt-guide.mdexamples/openclaw-plugin/setup-helper/install.js,examples/openclaw-plugin/install.sh,bot/scripts/install_local_openclaw_plugin.shMaintainer impact
Suggested fix rationale
PromptManager.render()execution path.Reference patterns from other software
Type of change
Test plan
cd /tmp/OpenViking-pr && python3 -m pytest -o addopts='' tests/test_prompt_manager.py tests/misc/test_prompt_manager_security.py -qcd /tmp/OpenViking-pr && ruff check openviking/prompts/manager.py openviking_cli/utils/config/prompts_config.py tests/test_prompt_manager.py tests/misc/test_prompt_manager_security.pycd /tmp/OpenViking-pr && node --check examples/openclaw-plugin/setup-helper/install.jscd /tmp/OpenViking-pr && bash -n examples/openclaw-plugin/install.shcd /tmp/OpenViking-pr && bash -n bot/scripts/install_local_openclaw_plugin.shPromptManagerblocks unsafe Jinja attribute traversal without creating the marker filepostinstallpayload during installExecuted with:
cd /tmp/OpenViking-pr && python3 -m pytest -o addopts='' tests/test_prompt_manager.py tests/misc/test_prompt_manager_security.py -qcd /tmp/OpenViking-pr && ruff check openviking/prompts/manager.py openviking_cli/utils/config/prompts_config.py tests/test_prompt_manager.py tests/misc/test_prompt_manager_security.pycd /tmp/OpenViking-pr && node --check examples/openclaw-plugin/setup-helper/install.jscd /tmp/OpenViking-pr && bash -n examples/openclaw-plugin/install.shcd /tmp/OpenViking-pr && bash -n bot/scripts/install_local_openclaw_plugin.shDisclosure notes