chore: Add validation for operation slugs to prevent path traversal#264
Open
jkennedyvz wants to merge 1 commit intomainfrom
Open
chore: Add validation for operation slugs to prevent path traversal#264jkennedyvz wants to merge 1 commit intomainfrom
jkennedyvz wants to merge 1 commit intomainfrom
Conversation
Operation slugs are provided by the ASHIRT server or imported from export files and used to construct filesystem paths. Without validation, malicious slugs containing path traversal sequences (../, etc.) could cause evidence files to be written outside the intended evidence directory. Changes: 1. Added StringHelpers::isValidOperationSlug() function - Validates slug format (alphanumeric, hyphen, underscore only) - Rejects empty or overly long slugs (>128 chars) - Explicitly blocks path traversal patterns (.., /, \) 2. Applied validation in SystemHelpers::pathToEvidence() - Validates slugs from server at runtime - Logs warning and falls back to root evidence directory - Prevents compromised server from writing to arbitrary paths 3. Applied validation in SystemManifest::migrateDb() - Validates slugs from imported databases - Skips evidence with invalid slugs during import - Prevents malicious export files from exploiting path traversal Attack scenarios prevented: - Compromised ASHIRT server cannot write evidence to arbitrary locations - Malicious export files cannot perform path traversal during import - Social engineering attacks via crafted export files are mitigated Impact: - Defense in depth against server compromise - Protection against malicious import files - Maintains backward compatibility (valid slugs unchanged) Security: Fixes MEDIUM severity path traversal vulnerability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Operation slugs are provided by the ASHIRT server or imported from export files and used to construct filesystem paths. Without validation, malicious slugs containing path traversal sequences (../, etc.) could cause evidence files to be written outside the intended evidence directory.
Changes:
Added StringHelpers::isValidOperationSlug() function
Applied validation in SystemHelpers::pathToEvidence()
Applied validation in SystemManifest::migrateDb()
Attack scenarios prevented:
Impact:
Security: Fixes MEDIUM severity path traversal vulnerability
I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.