Skip to content

Sanitize method names to prevent path traversal attacks#595

Closed
Copilot wants to merge 2 commits intokdf/auto-issuesfrom
copilot/sub-pr-572
Closed

Sanitize method names to prevent path traversal attacks#595
Copilot wants to merge 2 commits intokdf/auto-issuesfrom
copilot/sub-pr-572

Conversation

Copy link

Copilot AI commented Nov 11, 2025

Addresses path traversal vulnerability where malicious issue data could inject method names like ../../etc/passwd to write files outside intended directories.

Changes

  • Added sanitizePath() method: Removes path traversal sequences (../, ..\\), slashes, and restricts to alphanumeric + _-: characters
  • Sanitize all path inputs: Applied to convertMethodToPath(), determineApiVersion(), and generateMethodDocumentation() before file path construction
// Before: vulnerable to traversal
convertMethodToPath(method) {
  return method.replace(/::/g, '-');
}

// After: sanitized input
sanitizePath(input) {
  let sanitized = input.replace(/\.\./g, '')
                      .replace(/^[/\\]+/, '')
                      .replace(/[/\\]/g, '')
                      .replace(/[^a-zA-Z0-9_:-]/g, '');
  return sanitized;
}

convertMethodToPath(method) {
  const sanitized = this.sanitizePath(method);
  return sanitized.replace(/::/g, '-');
}

Input ../../etc/passwd now becomes etcpasswd while task::enable_utxo::init correctly becomes task-enable_utxo-init.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: gcharang <21151592+gcharang@users.noreply.github.com>
Copilot AI changed the title [WIP] Update path sanitization in response to review comments Sanitize method names to prevent path traversal attacks Nov 11, 2025
Copilot AI requested a review from gcharang November 11, 2025 15:10
@gcharang gcharang closed this Nov 11, 2025
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.

2 participants