Skip to content

Conversation

@pgrayy
Copy link
Member

@pgrayy pgrayy commented Aug 15, 2025

Description

Fixing a vulnerability in the file and s3 session managers where customers can manipulate the storage paths through session id.

from strands.session.file_session_manager import FileSessionManager

FileSessionManager(session_id="../../private", storage_dir="./")

Currently, session_id is appended to the storage path without first being sanitized. Doing the above could lead the session manager to add or remove files from a restricted directory. This is a risk for Strands customers that obtain session_id from a third party.

This PR fixes the issue by raising an exception if the session_id contains separators.

Related Issues

Issue raised to the team internally.

Documentation PR

Updated the API docs through docstrings in this PR.

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare: Wrote new unit tests.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pgrayy pgrayy marked this pull request as ready for review August 15, 2025 20:28
zastrowm
zastrowm previously approved these changes Aug 15, 2025
Copy link
Member

@zastrowm zastrowm left a comment

Choose a reason for hiding this comment

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

Some nits/organizational items

@pgrayy pgrayy merged commit 8c63d75 into strands-agents:main Aug 15, 2025
13 of 14 checks passed
dbschmigelski pushed a commit to dbavro19/sdk-python that referenced this pull request Aug 28, 2025
This was referenced Sep 17, 2025
Unshure pushed a commit to Unshure/sdk-python that referenced this pull request Sep 24, 2025
@pgrayy pgrayy deleted the sanitize branch October 2, 2025 18:37
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.

3 participants