fix: add shlex.quote to all remote shell commands in filesystem.py (#154) - #156
Conversation
|
Thank you for this — the vulnerability is real, your diagnosis of it is correct, and you found it independently. Eight of the nine sites in this diff are fixed properly, and the two There is one blocking problem, and then some scope that the issue asks for. Blocking:
|
|
@aditya226-sharma thank you for your contribution! i had @claude review and it found a few issues; i'll have it post a comment in case you're up for addressing them. |
|
ah-- it beat me to it 😄 . but: let me know if you have any questions. |
|
Update, since you should hear it from us rather than by noticing the issue went quiet: #154 is now closed, fixed by a different approach. The blocking problem in this PR was the one I described above — quoting the pattern in Your two Some numbers, in case they are useful: an adversarial review then threw 14 payload families at the result — I am leaving this PR open rather than closing it, because that is the maintainer's call and not mine to make unilaterally. Thank you for the report. Finding a live command injection in a public API, diagnosing it correctly, and writing a patch for it is a real contribution, and the fact that the eventual fix took a different shape does not change that. If you want to pick something else up, #159 collects the defects that are live right now and each one has a reproduction in it. |
Summary
Adds
shlex.quote()to all nine remote shell commands infilesystem.pyto prevent command injection via unsanitized paths and glob patterns.Changes
import shlexto filesystem.pyls,stat,test -e,test -d,test -f,du -sb,findfind -name,ls -dshlex.quote()Why
Every one of these functions (
cluster_ls,cluster_find,cluster_stat,cluster_exists,cluster_isdir,cluster_isfile,cluster_glob,cluster_du,cluster_count_files) is public API reachable through documented convenience functions. A path or pattern carrying shell metacharacters runs as a command on the cluster, as the user, with their credentials. This is the same defect class PR #139 fixed inutils.py.Closes #154