security(environments): protect modal/singularity snapshot stores with owner-only perms - #60259
Closed
isheng-eqi wants to merge 8 commits into
Closed
security(environments): protect modal/singularity snapshot stores with owner-only perms#60259isheng-eqi wants to merge 8 commits into
isheng-eqi wants to merge 8 commits into
Conversation
The gateway already strips stale dangerous-confirmation text from replayed history (NousResearch#60110, NousResearch#60117 — fix for NousResearch#59607). The TUI gateway has two session resume paths that sanitize replay history but do not strip stale dangerous confirmations, leaving the same vulnerability unaddressed in TUI sessions. Add strip_stale_dangerous_confirmations() after sanitize_replay_history() in both TUI resume paths (resume_session and the WebUI resume path). Refs: NousResearch#59607, NousResearch#60110, NousResearch#60117
The recent Discord resource-bounding pass (NousResearch#60122, NousResearch#60112, NousResearch#60113) added limits for REST JSON/error response bodies and component label UTF-16 lengths. Four HTTP response reads for image/animation/attachment downloads were left unbounded — an oversized response from a CDN or external URL could OOM the bot. Add _DISCORD_IMAGE_DOWNLOAD_MAX_BYTES (50 MB) and _DISCORD_ATTACHMENT_DOWNLOAD_MAX_BYTES (100 MB) constants, a shared _read_response_bytes_bounded() helper, and apply bounds to: - Batch image download (adapter.py ~2467) - Single image download (adapter.py ~3555) - Animation/GIF download (adapter.py ~3634) - Attachment download (adapter.py ~5799) Refs: NousResearch#60122, NousResearch#60112
The profile-aware skills resolution fix (NousResearch#60180) added _skills_dir() to tools/skills_tool.py and tools/skill_manager_tool.py so that long-lived multi-profile runtimes always resolve the live profile-scoped HERMES_HOME. agent/skill_utils.py still referenced the module-level SKILLS_DIR constant, which would return stale import-time paths in the same long-lived runtimes. Replace _skills_tool.SKILLS_DIR with _skills_tool._skills_dir() in the normalize_skill_identifier() path, matching the pattern established in NousResearch#60180. Tests that patch SKILLS_DIR are unaffected — _skills_dir() falls back to the patched value when it differs from _SKILLS_DIR_AT_IMPORT. Refs: NousResearch#60180, NousResearch#40677
… runtimes Module-level _AUTH_JSON_PATH captures get_hermes_home() at import time. In long-lived multi-profile runtimes (Dashboard/TUI/Desktop backend), this path becomes stale when the active profile changes, causing auth token reads from the wrong profile (NousResearch#40677). Add _auth_json_path() that resolves from the live HERMES_HOME, matching the pattern established by _skills_dir() in NousResearch#60180. Refs: NousResearch#60180, NousResearch#40677
…n profile scope After NousResearch#60180, _skills_dir() resolves SKILLS_DIR at call time via the live get_hermes_home(). The manual monkeypatching of _skills_tool.SKILLS_DIR/HERMES_HOME and _skill_mgr.SKILLS_DIR/HERMES_HOME in _profile_scope() is no longer necessary — set_hermes_home_override() alone suffices. Remove the redundant patching, drop the unused module imports, and update stale docstrings in both _profile_scope() and _config_profile_scope(). Refs: NousResearch#60180, NousResearch#40677
…-lived runtimes get_skill_commands() caches scanned skills in module-level _skill_commands and only invalidates when the active platform changes (NousResearch#14536). In long-lived multi-profile runtimes (Dashboard/TUI/Desktop backend), the cache is not invalidated when the active profile changes, causing the wrong profile's skills to appear in the slash-command map. Add _skill_commands_skills_dir tracking alongside the existing platform check. On each get_skill_commands() call, compare the cached skills_dir against the current _skills_dir() — if they differ (profile change), rescan. Also update scan_skill_commands() to use _skills_dir() (call-time resolution, NousResearch#60180) instead of the module-level SKILLS_DIR constant. Refs: NousResearch#60180, NousResearch#40677, NousResearch#14536
…er-only perms and profile-awareness Two fixes completing the NousResearch#60199 security hardening + NousResearch#60180 profile-awareness: 1. Security: _save_json_store() writes snapshot data (which may contain env-carried secrets) without umask protection. Add os.umask(0o077) guard matching the env snapshot write fix in NousResearch#60199. 2. Profile-awareness: _SNAPSHOT_STORE in modal.py and singularity.py captured get_hermes_home() at import time. Replace with call-time _snapshot_store_path() resolvers so the live profile-scoped HERMES_HOME is always respected in long-lived multi-profile runtimes (NousResearch#40677). Refs: NousResearch#60199, NousResearch#60180, NousResearch#40677
Collaborator
Part of the profile-awareness stacked chain (#60180 base merged → #60231/#60241/#60254/#60257/#60259). Note: this PR's diff carries 6 files (auxiliary_client, skill_commands, skill_utils, web_server, discord adapter, tui_gateway/server) that are byte-identical to the earlier stack siblings — the unique change is the |
Contributor
Author
Contributor
Author
|
Branch contaminated — rebuilding with clean base. |
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.
What does this PR do?
Two fixes: (1)
_save_json_store()writes snapshot data without umask — addumask 077like #60199. (2)_SNAPSHOT_STOREmodule-level constants in modal/singularity stale in multi-profile runtimes (#40677).Related Issue
Fixes sibling paths of #60199 and #60180.
Type of Change
Changes Made
tools/environments/base.py: Add umask guardtools/environments/modal.py: Replace constant with_snapshot_store_path()tools/environments/singularity.py: Replace constant with_snapshot_store_path()