securityfilesystem
Filesystem Security security skill
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Filesystem Security
File operations have race conditions, symlink attacks, and path traversal risks.
ikigai Application
Path traversal:
- Reject paths containing
..before canonicalization - Use
realpath()and verify result is under allowed directory - Never concatenate user input directly into paths
TOCTOU (Time-of-Check to Time-of-Use):
// BAD: Race between check and use
if (access(path, R_OK) == 0) { fd = open(path, O_RDONLY); }
// GOOD: Open first, then check
fd = open(path, O_RDONLY);
if (fd >= 0) { /* use fd */ }
Symlink attacks:
- Use
O_NOFOLLOWwhen opening files in shared directories -
lstat()to check for symlinks before operations - Create temp files with
mkstemp(), nevermktemp()
Permissions:
- Config files:
0600(owner read/write only) - Directories:
0700 - Check permissions before reading sensitive files
- Set umask appropriately:
umask(077)
Review red flags: access() before open(), path concatenation, missing O_NOFOLLOW, world-readable configs.
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!