securitysecure-c
Secure C Coding 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
Secure C Coding
Avoid dangerous functions, use safe alternatives, enable compiler hardening.
Banned Functions → Safe Alternatives
| Banned | Why | Use Instead |
|---|---|---|
strcpy |
No bounds | strncpy, strlcpy, snprintf |
strcat |
No bounds | strncat, strlcat |
sprintf |
No bounds | snprintf |
gets |
Always unsafe | fgets |
scanf("%s") |
No bounds | scanf("%Ns") with width |
mktemp |
Race condition | mkstemp |
atoi |
No error detection | strtol with validation |
Compiler Hardening
CFLAGS += -fstack-protector-strong # Stack canaries
CFLAGS += -D_FORTIFY_SOURCE=2 # Runtime buffer checks
CFLAGS += -fPIE -pie # ASLR for executables
LDFLAGS += -Wl,-z,relro,-z,now # GOT protection
Static Analysis
-
make lint- clang-tidy checks -
cppcheck --enable=all - Compiler warnings:
-Wall -Wextra -Werror
Review red flags: Any banned function, missing bounds on string ops, char buf[N] with unchecked input.
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!