T09 · Insecure Skill Coding Practices
- Location
scripts/lib/namespace.sh:65- Finding
Path Traversal Enables Recursive Deletion Outside the Namespace Directory
- Content
View full analysis
&2 return 1 fi local ns_dir="$NAMESPACE_DIR/$name" if [[ ! -d "$ns_dir" ]]; then echo "Namespace '$name' does not exist" return 1 fi read -p "Delete namespace '$name' and all its data? (y/N) " confirm if [[ "$confirm" != "y" ]]; then echo "Cancelled" return 0 fi rm -rf "$ns_dir" echo "Deleted namespace: $name" } ``` The corresponding command handler passes the user-provided value directly to this function: ```bash delete) shift namespace_delete "$@" ;; ``` ### Technical Analysis The namespace name is concatenated directly with `NAMESPACE_DIR` without validation or canonicalization. Names containing path separators and `..` components can resolve outside the intended namespace directory. The only protected value is the literal default namespace name. There is no check that the resolved deletion target remains a direct child of `NAMESPACE_DIR`. The existence check does not provide containment protection; it merely confirms that the traversed target is a directory. The confirmation prompt displays the untrusted namespace string rather than the canonical deletion target. It therefore does not adequately inform the user which directory will actually be removed. ### Attack Path 1. An attacker persuades a user or automation process to execute a namespace deletion using a traversal value, such as: ```bash unified-self-improving namespace delete ../hot ``` 2. The value is passed unchanged to `namespace_delete`. 3. The constructed path becomes: ```text $MEMORY_ROOT/namespace ...[truncated 1000 chars]- Remediation
View remediation
&2 return 1 } ``` 5. Refuse to delete the root itself, symbolic links, or unexpected filesystem objects. 6. Display the canonical target path in the confirmation prompt. 7. Apply the same namespace validator consistently in create, delete, use, import, query, recall, and move operations. ]]>
