Repository navigation
fix: redact credentials from URLs in logs, exceptions, and persisted state - #2196
jpshackelford wants to merge 1 commit into
Conversation
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste - Clean security fix with pragmatic design.
Key Insight: Simple regex-based redaction applied consistently across logs, exceptions, and persisted state. The decision to redact credentials in ResolvedPluginSource is sound design - credentials are only needed at fetch time, and resolved plugins reference local cached paths for subsequent access.
What Works:
- Focused
redact_url_credentials()function does one thing well - Comprehensive test coverage testing real behavior (not mocks) ✓
- Handles edge cases correctly (ports, special chars, SSH URLs unchanged)
- Applied consistently: logs, error messages, exceptions, persistence
Design Decision (Good):
Redacting in ResolvedPluginSource.from_plugin_source() prevents credential leakage in conversation state without breaking functionality - resolved plugins use cached repo_path, so re-authentication not needed.
✅ Worth merging - Solves real security problem (#2152) with minimal complexity. No agent behavior changes, just safer logging and persistence.
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@OpenHands Do a /codereview-roasted on this PR, and publish your review using gh API and event. |
|
I'm on it! enyst can track my progress at all-hands.dev |
enyst
left a comment
There was a problem hiding this comment.
🔴 Needs improvement - you added a redaction helper, but the security boundary is still full of holes.
Linus-Style Analysis
[CRITICAL ISSUES]
openhands-sdk/openhands/sdk/plugin/loader.py:75,openhands-sdk/openhands/sdk/plugin/installed.py:195,582,openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py:350Security / real-world leak: the PR says credentials are redacted from logs, but these paths still logsource/spec.sourceverbatim. So a completely successful plugin load or install can still dump the credentialed URL into logs. That's not a corner case; that's the normal path. The fix needs one redaction boundary that's used everywhere plugin sources are logged, not a few hand-picked call sites.openhands-sdk/openhands/sdk/plugin/installed.py:103-118,openhands-sdk/openhands/sdk/plugin/installed.py:227-241Persisted-state leak:InstalledPluginInfo.from_plugin()stores the originalsourceunchanged, andInstalledPluginsMetadata.save_to_dir()writes it to disk. So authenticated plugin URLs still end up persisted in metadata. If the goal is "credentials do not live in persisted state", this path still fails it.
[TESTING GAPS]
tests/sdk/git/test_credential_redaction.py:1-186Helper tests aren't enough: these tests mostly prove that a regex rewrites strings. They do not exercise the behavior that matters: actual log messages and persistence paths fromrun_git_command(), plugin install/load, conversation plugin loading, or installed metadata. Right now the tests all pass while the leak is still present in live call sites, which means the regression net is pointed at the wrong thing.
VERDICT:
❌ Needs rework: the helper itself is fine, but the security fix is incomplete, so this PR does not actually eliminate credential exposure.
KEY INSIGHT:
You added a scrubber, but you did not make it the single choke point, so raw URLs are still escaping through ordinary success-path code.
This comment was marked as duplicate.
This comment was marked as duplicate.
|
I haven't verified if the agent is accurate or not, just FWIW, the second thing it says might be happening because we got in a PR installing plugins ... maybe between the time you first made this and now. Sorry! So now there might be another execution path indeed. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
9 similar comments
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
…state This addresses security issue #2152 by preventing credential leakage: - Add redact_url_credentials() utility function to sanitize URLs with embedded credentials (e.g., https://oauth2:token@host/path becomes https://****@host/path) - Update git/utils.py:run_git_command() to redact credentials from: - Error log messages - Debug log messages - GitCommandError exception messages and command fields - Update git/cached_repo.py to redact credentials in clone log messages - Update extensions/fetch.py to redact credentials in: - ExtensionFetchError exception messages - Warning log messages - Update plugin/types.py:ResolvedPluginSource.from_plugin_source() to redact credentials before persistence (credentials only needed at fetch time) - Update plugin/loader.py to redact credentials in plugin load log messages - Update local_conversation.py to redact credentials in plugin load logs - Update extensions/installation/info.py to redact credentials before persisting installed extension metadata - Export redact_url_credentials from openhands.sdk public API for cross-repo usage (related: OpenHands/OpenHands#12959) - Add comprehensive tests for credential redaction Fixes #2152 Co-authored-by: John-Mason P. Shackelford <jpshackelford@users.noreply.github.com>
7d02066 to
8aacb37
Compare
PR Updated 🔄I've rebased this PR on latest Changes in this update:
Ready for re-review! 🚀 This update was created by an AI agent (OpenHands) on behalf of @jpshackelford. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. This comment was created by an AI agent (OpenHands) on behalf of the user. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. This comment was generated by an AI agent (OpenHands) on behalf of the user. |
|
[Automatic Post]: This PR seems to be currently waiting for review. @enyst, could you please take a look when you have a chance? This comment was created by an AI agent (OpenHands) on behalf of the user. |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. This comment was created by an AI agent (OpenHands) on behalf of the user. |
1 similar comment
|
[Automatic Post]: It has been a while since there was any activity on this PR. @jpshackelford, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. This comment was created by an AI agent (OpenHands) on behalf of the user. |
|
Closing the loop — superseding this PR. This PR took a per-call-site "scrubber" approach, which the review #2196 (review 3950231707) correctly flagged as architecturally incomplete (no single choke point, so raw URLs still escape via success-path and persisted-state code). The work has since been reworked and split into focused, reviewable pieces. Closing this to stop the stale-bot churn — nothing here is lost; every site is now either fixed on Done / merged
In progress / tracked
Umbrella context: original SDK report #2152, OpenHands-side #12959. Re-open or rebase only if a site surfaces that none of #2154 / #3689 / #3751 / #3752 covers. Posted by an AI agent (OpenHands) on behalf of @jpshackelford. |
Summary
Fixes #2152
This PR addresses a security issue where credentials embedded in plugin source URLs (e.g.,
https://oauth2:SECRET_TOKEN@gitlab.com/org/private-repo) were being exposed in:ResolvedPluginSource.installed.jsonChanges
redact_url_credentials(url)ingit/utils.pythat replaces credentials in URLs with****(e.g.,https://****@gitlab.com/org/repo)run_git_command(): Redacts credentials from error logs, debug logs, andGitCommandErrorexception messages/command fieldscached_repo.py: Redacts credentials in clone log messagesextensions/fetch.py: Redacts credentials inExtensionFetchErrorexceptions and warning logs (this is the new location after refactoring)plugin/types.py:ResolvedPluginSource.from_plugin_source()now redacts credentials before persistence (credentials are only needed at fetch time)plugin/loader.py: Redacts credentials in plugin loading log messageslocal_conversation.py: Redacts credentials in plugin loaded debug messagesextensions/installation/info.py: Redacts credentials inInstallationInfo.from_extension()before persisting to.installed.jsonredact_url_credentialsis exported fromopenhands.sdkfor cross-repo usage (related to Security: Credentials in plugin source URLs exposed via API responses OpenHands#12959)Example
Before:
After:
Code Review Feedback Addressed
This update addresses all the issues identified in the code review by @enyst:
plugin/loader.py- now redactsspec.sourcein log messageslocal_conversation.py- now redactsspec.sourcein debug log messagesextensions/installation/info.py- now redacts source inInstallationInfo.from_extension()before persistenceRebased to Resolve Conflicts
The codebase was significantly refactored since the original PR (fetch logic moved from
plugin/fetch.pytoextensions/fetch.py). This update is rebased on latestmainand applies redaction to the new code locations.Checklist
This PR was updated by an AI agent (OpenHands) on behalf of @jpshackelford.
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:8aacb37-pythonRun
All tags pushed for this build
About Multi-Architecture Support
8aacb37-python) is a multi-arch manifest supporting both amd64 and arm648aacb37-python-amd64) are also available if needed