Skip to content

feat: restore security validation and add unified download tools - #2

Open
erphenheimer wants to merge 3 commits into
tsingyuai:mainfrom
erphenheimer:security/restore-validation-and-download-tools
Open

feat: restore security validation and add unified download tools#2
erphenheimer wants to merge 3 commits into
tsingyuai:mainfrom
erphenheimer:security/restore-validation-and-download-tools

Conversation

@erphenheimer

Copy link
Copy Markdown

Summary

v3.0.0 simplified the architecture but removed all input validation (security.ts was deleted entirely). This PR restores security protections while preserving v3's lean design:

  • Restore src/utils/security.ts with validateProjectId, validateArxivId, validateDoi, ensureWithinDirectory
  • Apply validation in CLI (research.ts) and commands (commands.ts) to prevent path traversal
  • Add unified paper_download tool (merges arxiv-download + unpaywall-download, validates all identifiers)
  • Add paper_browser tool for paginated reading of large papers
  • Remove unsafe bash template skill (skills/paper-download/) — replaced by typed tool with input validation
  • Update SKILL.md references and documentation

Motivation

The v3.0.0 refactor deleted src/utils/security.ts which contained critical protections against:

  • Path traversal: LLM-generated project IDs like ../../etc could escape the workspace
  • Shell injection: bash templates in SKILL.md passed unvalidated arXiv IDs to shell commands
  • Identifier injection: No validation on arXiv IDs or DOIs before use in HTTP requests

This PR adds ~350 lines of focused security + tooling code without reverting v3's architectural simplification (~7500 lines removed).

Test plan

  • npm run build passes with no TypeScript errors
  • validateProjectId rejects ../../etc, accepts my-project-1
  • validateArxivId rejects ; rm -rf /, accepts 2401.12345
  • ensureWithinDirectory blocks path traversal attempts
  • paper_download tool validates IDs before making HTTP requests

@erphenheimer erphenheimer reopened this Mar 31, 2026
@erphenheimer
erphenheimer deleted the security/restore-validation-and-download-tools branch March 31, 2026 11:14
@erphenheimer

Copy link
Copy Markdown
Author

对不起,我第一次搞这个不太懂,我回去研究研究,抱歉

@erphenheimer
erphenheimer restored the security/restore-validation-and-download-tools branch March 31, 2026 11:22
@erphenheimer erphenheimer reopened this Mar 31, 2026
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