Skip to content

security: fix path traversal in agent builder and documentation micro-fixes#5599

Open
Kaushikj-7 wants to merge 3 commits intoaden-hive:mainfrom
Kaushikj-7:main
Open

security: fix path traversal in agent builder and documentation micro-fixes#5599
Kaushikj-7 wants to merge 3 commits intoaden-hive:mainfrom
Kaushikj-7:main

Conversation

@Kaushikj-7
Copy link

Description

This PR addresses a critical security vulnerability and improves documentation clarity.

Type of Change

  • Bug fix (non-breaking change that fixes a security issue)
  • Documentation update
  • New feature (added path validation unit tests)

Related Issues

N/A (Security audit finding)

Changes Made

  • Security: Added robust path validation to agent_builder_server.py to prevent path traversal in
    session and export tools.
  • Testing: Added a new test suite core/tests/test_agent_builder_path_traversal.py using unittest
    to verify protection against malicious paths.
  • Docs: Fixed typos and clarified terminology in getting-started.md, developer-guide.md, and other
    core files.

Testing

  • Unit tests pass (python -m unittest core/tests/test_agent_builder_path_traversal.py)
  • Manual verification of security fix using a reproduction script.

Checklist

  • My code follows the project's style guidelines
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally

Copy link
Author

@Kaushikj-7 Kaushikj-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Vulnerability Addressed:
    I identified a path traversal risk in agent_builder_server.py where user-provided session_id and
    agent_path parameters were used directly in filesystem operations (unlink, mkdir, read_text). A
    malicious input could have allowed an attacker to read or delete files outside of the intended
    directories.

  2. The Fix:

  • _safe_path_segment: Now strictly enforces that session IDs contain no path separators (/, )
    or parent directory references (..).
  • _safe_export_path: Uses .resolve() and a prefix check to ensure that all agent exports and
    imports are strictly confined to the exports/ directory, preventing escapes to sensitive system
    areas.
  1. Test Coverage (see core/tests/test_agent_builder_path_traversal.py):
    I added a new test suite that verified the following:
  • Success Cases: Valid alphanumeric session IDs and local export paths work as expected.
  • Traversal Blocking: Confirmed that inputs like ../../etc/passwd or sub/dir trigger a ValueError.
  • Integrity Check: Verified that delete_session successfully blocks a deletion attempt targeting a
    file outside the restricted sessions directory.
  1. Documentation:
    Corrected terminology for "builder skills" to match the project's internal naming conventions and
    fixed minor typos.

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