T09 · Insecure Skill Coding Practices
- Location
scripts/context-manager.py:135- Finding
Sensitive memory content exposed through command-line arguments and terminal output
- Content
View full analysis
Vulnerability Details
File Location:
scripts/context-manager.py, lines 135-150
Vulnerability Type: Sensitive-data exposure through process arguments, shell history, and output
Risk Level: MediumVulnerable Code
python parser = argparse.ArgumentParser(description='智能上下文管理系统') parser.add_argument('--init', action='store_true', help='初始化系统') parser.add_argument('--add', type=str, help='添加记忆') parser.add_argument('--importance', type=float, default=1.0, help='记忆重要性') parser.add_argument('--stats', action='store_true', help='显示统计信息') parser.add_argument('--auto-manage', action='store_true', help='自动管理') parser.add_argument('--model', type=str, default='kiro/claude-haiku-4-5', help='指定模型') args = parser.parse_args() manager = ContextManager() if args.init: print("✅ 系统已初始化") print(f"📁 数据库位置: {manager.db_path}") elif args.add: manager.add_memory(args.add, args.importance) print(f"✅ 已添加记忆: {args.add[:50]}...")The documented invocation also encourages direct placement of memory content in a command-line argument:
bash python3 scripts/context-manager.py --add "你的记忆内容" --importance 0.9Technical Analysis
The
--addoption accepts potentially sensitive memory content directly through the process command line. Depending on the operating system and its configuration, command-line arguments can be exposed through:- Shell history files.
- Process inspection utilities and process metadata.
- Job-control or process-monitoring services.
- Audit logs, command wrappers, or orchestration logs.
- Terminal session recording.
After the memory is stored, the program also prints its first 50 characters. This can copy sensitive content into terminal logs, CI logs, chatbot execution transcripts, or monitoring systems.
This exposure is unnecessary for the declared memory-management functionality. The program only needs the content internally and does not ...[truncated 1369 chars]
- Remediation
View remediation
Remediation Suggestions
-
Accept sensitive memory content through standard input rather than a command-line argument, for example:
python import sys if args.add_stdin: content = sys.stdin.read() manager.add_memory(content, args.importance) -
Provide an interactive input mode. If the content is expected to be secret and single-line, use
getpass.getpass()to prevent terminal echo. -
If file-based input is supported, require an explicit protected input file and validate that it is a regular file with appropriately restrictive permissions.
-
Do not print any portion of the submitted content. Return only a non-sensitive confirmation, such as the new memory identifier.
-
Deprecate or prominently warn about
--add VALUEbecause command-line arguments cannot reliably be kept secret. -
Update
README.mdandSKILL.mdso examples use stdin or another protected input mechanism. -
Avoid logging raw memory content and add tests confirming that secrets are absent from standard output and error messages.
-
