Summary
Wish's Git middleware can allow authenticated SSH users to escape the configured repository directory by supplying crafted repository paths. Depending on the Git operation and filesystem permissions, this may let them read or modify repositories outside the intended root.
Affected context
The vulnerability affects Wish deployments using the Git middleware with a configured repository root. The middleware's forward-slash-count containment check can fail to identify paths that traverse outside that root, including single-depth traversal paths and, on Windows, backslash-based paths.
Exploit preconditions
- Attack surface: The Git middleware exposed over SSH
- Required access: An authenticated SSH account able to invoke Git operations through the middleware
- Trigger point: The middleware processes a supplied repository path for
git-upload-pack,git-upload-archive, orgit-receive-pack - Why exploitation is possible: A flawed forward-slash-count check may not detect paths that resolve outside the configured repository directory
Why this happens
The middleware uses a separator-counting check to assess whether a repository path remains within an intended directory. Counting forward slashes does not reliably establish path containment: traversal segments can escape the root, and Windows backslashes can bypass a check focused on forward slashes. This is a path traversal weakness, mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
Potential impact
- Authenticated users may read repository data outside the configured root through Git read operations.
- Users may modify repositories outside the intended root through Git write operations, subject to the service's permissions.
- Repository confidentiality or integrity could be compromised.
- Additional systems or workflows relying on affected repositories could be exposed to follow-on risk.
General mitigation guidance
Mitigation patterns focus on enforcing directory boundaries independently of path formatting:
- Resolve and normalize repository paths using platform-aware filesystem APIs, then verify that the resolved target remains beneath the canonical repository root.
- Reject traversal segments and unexpected path forms rather than relying on separator counts.
- Use secure-by-default path handling and avoid allowing clients to select arbitrary filesystem locations.
- Restrict SSH access and apply least-privilege filesystem permissions to repository operations.
- Separate read and write capabilities where practical, and limit each account to the repositories it needs.
How teams detect issues like this
- Review path-handling code for checks based on separator counts, string prefixes, or assumptions about slash direction.
- Use static analysis rules to flag user-controlled paths passed to filesystem or Git operations without canonical containment validation.
- Test path validation across supported operating systems and with both separator styles.
- Enforce policies requiring canonical-path containment checks and least-privilege access for Git middleware.
- Automated code review tools may help identify risky path construction and validation patterns.

