Skip to content

Security: Path traversal risk in file-reading helper methods#2916

Open
tuanaiseo wants to merge 1 commit intoc3js:masterfrom
tuanaiseo:contribai/fix/security/path-traversal-risk-in-file-reading-help
Open

Security: Path traversal risk in file-reading helper methods#2916
tuanaiseo wants to merge 1 commit intoc3js:masterfrom
tuanaiseo:contribai/fix/security/path-traversal-risk-in-file-reading-help

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

Helper methods build file paths by string concatenation (e.g., open("docs/js/samples/" + id + ".js")) without sanitizing id/name. If these values can be influenced externally, attackers may read unintended files via traversal sequences.

Severity: medium
File: config.rb

Solution

Validate inputs against strict allowlists (expected sample names), normalize paths, and enforce that resolved paths remain within intended directories before opening files.

Changes

  • config.rb (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

Helper methods build file paths by string concatenation (e.g., `open("docs/js/samples/" + id + ".js")`) without sanitizing `id`/`name`. If these values can be influenced externally, attackers may read unintended files via traversal sequences.

Affected files: config.rb

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
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.

1 participant