security/secure-c

Secure C Coding security skill

$ 安裝

git clone https://github.com/mgreenly/ikigai /tmp/ikigai && cp -r /tmp/ikigai/.claude/library/security/secure-c ~/.claude/skills/ikigai

// tip: Run this command in your terminal to install the skill


name: security/secure-c description: Secure C Coding security skill

Secure C Coding

Avoid dangerous functions, use safe alternatives, enable compiler hardening.

Banned Functions → Safe Alternatives

BannedWhyUse Instead
strcpyNo boundsstrncpy, strlcpy, snprintf
strcatNo boundsstrncat, strlcat
sprintfNo boundssnprintf
getsAlways unsafefgets
scanf("%s")No boundsscanf("%Ns") with width
mktempRace conditionmkstemp
atoiNo error detectionstrtol 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.