KS
Killer-Skills

c-audit — how to use c-audit how to use c-audit, c-audit setup guide, c-audit alternative, c-audit vs other audit tools, c-audit install, what is c-audit, c-audit memory safety, c-audit security audit, c-audit quality audit

v1.0.0
GitHub

About this Skill

Ideal for Code Review Agents requiring in-depth C code analysis and security auditing capabilities. c-audit is a local-first application platform that runs anywhere, providing a single binary with zero dependencies for auditing C code.

Features

Performs comprehensive security, safety, and quality audits on Hull C code
Audits specific files or all source files in src/cap/, src/runtime/, and include/hull/
Identifies memory safety issues with critical severity
Applies fixes to audited code using the --fix command
Runs as a single binary with zero dependencies

# Core Topics

artalis-io artalis-io
[6]
[1]
Updated: 3/3/2026

Quality Score

Top 5%
54
Excellent
Based on code quality & docs
Installation
SYS Universal Install (Auto-Detect)
Cursor IDE Windsurf IDE VS Code IDE
> npx killer-skills add artalis-io/hull/c-audit

Agent Capability Analysis

The c-audit MCP Server by artalis-io is an open-source Categories.community integration for Claude and other AI agents, enabling seamless task automation and capability expansion. Optimized for how to use c-audit, c-audit setup guide, c-audit alternative.

Ideal Agent Persona

Ideal for Code Review Agents requiring in-depth C code analysis and security auditing capabilities.

Core Value

Empowers agents to perform comprehensive security, safety, and quality audits on Hull C code, targeting source files and applying fixes using Memory Safety and other audit categories, including src/cap/, src/runtime/, and include/hull/ directories.

Capabilities Granted for c-audit MCP Server

Auditing C code for critical memory safety issues
Applying automated fixes to identified security vulnerabilities
Performing quality audits on Hull C source files

! Prerequisites & Limits

  • Requires access to Hull C codebase
  • Limited to auditing C code in specific directories (src/cap/, src/runtime/, include/hull/)
Project
SKILL.md
10.3 KB
.cursorrules
1.2 KB
package.json
240 B
Ready
UTF-8

# Tags

[No tags]
SKILL.md
Readonly

C Code Audit Skill

Perform comprehensive security, safety, and quality audits on Hull C code.

Target: $ARGUMENTS (default: all src/cap/, src/runtime/, and include/hull/ files)

Usage

/c-audit                              # Audit all source files
/c-audit src/cap/hull_cap_db.c        # Audit a specific file
/c-audit --fix                        # Audit and apply fixes

Audit Categories

1. Memory Safety (Critical)

IssuePattern to FindSeverity
Buffer overflowstrcpy, strcat, sprintf, gets, unbounded loopsCritical
Unbounded string opsstrlen, strcmp on untrusted inputCritical
Unsafe integer parsingatoi, atol, atof (no error detection, no bounds)High
Integer overflowmalloc(a * b) without overflow checkCritical
Use-after-freePointer used after free()Critical
Double-freefree() called twice on same pointerCritical
Null dereferencePointer used without NULL checkHigh
Uninitialized memoryVariables used before assignmentHigh
Missing null terminatorString buffer not explicitly terminatedHigh
Memory leakmalloc without corresponding freeMedium
Stack buffer overflowLarge stack arrays, VLAsMedium

Safe Replacements:

c
1// Copying 2strcpy(dst, src) -> strncpy(dst, src, sizeof(dst)-1); dst[sizeof(dst)-1] = '\0'; 3strcat(dst, src) -> strncat(dst, src, sizeof(dst)-strlen(dst)-1); 4 5// Formatting 6sprintf(buf, fmt, ...) -> snprintf(buf, sizeof(buf), fmt, ...); 7gets(buf) -> fgets(buf, sizeof(buf), stdin); 8 9// Memory allocation (overflow-safe) 10malloc(count * size) -> calloc(count, size); 11 12// Integer parsing (atoi/atol have no error detection!) 13atoi(str) -> strtol(str, &end, 10) with validation 14atof(str) -> strtof(str, &end) with validation

Allocator Discipline:

c
1// Hull uses malloc/free directly (no custom allocator like Keel) 2// Verify: every malloc has a matching free 3// Verify: every malloc return is checked for NULL 4// Verify: calloc used when count*size multiplication is needed 5 6// BAD: 7void *p = malloc(count * elem_size); // overflow risk 8 9// GOOD: 10void *p = calloc(count, elem_size); // overflow-safe 11if (!p) return -1;

2. Input Validation

IssueWhat to Check
Array boundsAll array indices validated before access
Pointer validityNULL checks before dereference
Size parametersNon-negative, within reasonable bounds
String lengthLength checked before copy/concat
Numeric rangesValues within expected domain
SQL parametersparam_count checked before binding in hl_cap_db_*
File pathsPath validation via hl_cap_fs_validate() before any I/O
Env allowlistVariable name checked against allowlist in hl_cap_env_get()

3. Resource Management

IssueWhat to Check
File descriptorsfopen paired with fclose
Memorymalloc/calloc paired with free
SQLitesqlite3_open paired with sqlite3_close
SQLite statementssqlite3_prepare_v2 paired with sqlite3_finalize
QuickJS runtimeJS_NewRuntime paired with JS_FreeRuntime
QuickJS contextJS_NewContext paired with JS_FreeContext
Lua statelua_newstate paired with lua_close
Error pathsResources freed on all exit paths
I/O return valuesfwrite/fread return values checked

Hull Cleanup Pattern:

c
1// Every init must have matching free 2hl_js_init() -> hl_js_free() 3hl_lua_init() -> hl_lua_free() 4sqlite3_open() -> sqlite3_close() 5sqlite3_prepare_v2() -> sqlite3_finalize() 6JS_NewRuntime() -> JS_FreeRuntime() 7JS_NewContext() -> JS_FreeContext() 8lua_newstate() -> lua_close() 9fopen() -> fclose()

4. Integer Overflow

Overflow in size computations can cause undersized allocations and buffer overflows.

c
1// BAD: overflow on 32-bit 2int total = count * sizeof(HlColumn); 3void *buf = malloc(total); 4 5// GOOD: use size_t + calloc 6HlColumn *cols = calloc(count, sizeof(HlColumn)); 7 8// GOOD: check before multiply 9if (count > 0 && (size_t)count > SIZE_MAX / sizeof(HlColumn)) { 10 return -1; // overflow 11}

Key areas in Hull:

  • HlColumn array allocation in hl_cap_db_query() row callbacks
  • PBKDF2 output buffer sizing
  • SQL parameter arrays (HlValue binding arrays)
  • Filesystem path buffer construction (base_dir + "/" + relative_path)
  • QuickJS/Lua value conversion arrays

5. Capability Boundary Enforcement

Hull's security model depends on the shared hl_cap_* layer. Verify:

IssueSeverityWhat to Check
Direct SQLite callsCriticalJS/Lua bindings never call sqlite3_* directly
Direct file I/OCriticalJS/Lua bindings never call fopen/fread/fwrite directly
Path traversalCriticalhl_cap_fs_validate() called before every file operation
SQL injectionCriticalAll SQL uses parameterized binding via hl_cap_db_*
Env leakageHighAll env access through hl_cap_env_get() with allowlist
Sandbox escapeCriticaleval() removed, io/os libs not loaded, loadfile/dofile removed

6. Defensive Macros

Check for and suggest these patterns:

c
1#define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0])) 2#define SAFE_FREE(p) do { free(p); (p) = NULL; } while(0) 3#define CLAMP(x, lo, hi) ((x) < (lo) ? (lo) : ((x) > (hi) ? (hi) : (x)))

7. Test Coverage

Check test files (tests/test_*.c) for:

  • Basic functionality tests
  • Edge cases (empty input, max values, NULL)
  • Error path tests (what happens when things fail)
  • Bounds checking tests
  • All public API functions have at least one test
  • Path traversal rejection tested
  • SQL parameterization tested
  • Env allowlist enforcement tested
  • Sandbox restrictions tested (both JS and Lua)

8. Dead Code Detection

PatternIssueFix
if (0) { ... }Dead branchRemove
return; code_after;Unreachable codeRemove
#if 0 ... #endifDisabled codeRemove or document
Unused #defineDead macroRemove
Unused static functionDead functionRemove

Compile with -Wunused flags to detect automatically.

9. Build Hardening

Development build (make debug):

makefile
1-fsanitize=address,undefined -g -O0 -fno-omit-frame-pointer

Production build (make):

makefile
1-Wall -Wextra -Wpedantic -Wshadow -Wformat=2 2-fstack-protector-strong 3-O2

Full validation (make check):

makefile
1clean + DEBUG=1 build + test + e2e

Audit Checks:

  • -fstack-protector-strong in production CFLAGS
  • Debug build with ASan + UBSan available (make debug)
  • Full validation available (make check)
  • All tests pass under sanitizers
  • No compiler warnings with -Wall -Wextra -Wpedantic -Wshadow -Wformat=2

Audit Procedure

When /c-audit is invoked:

  1. Locate Files

    src/cap/*.c                 # Shared capability layer
    src/runtime/js/*.c          # QuickJS runtime integration
    src/runtime/lua/*.c         # Lua 5.4 runtime integration
    src/main.c                  # Entry point
    include/hull/*.h            # Public headers
    tests/test_*.c              # Test files
    Makefile                    # Build configuration
    
  2. Scan for Critical Issues

    • Search for unsafe functions: strcpy, sprintf, gets, strcat
    • Search for unsafe integer parsing: atoi, atol, atof
    • Search for unchecked allocations: malloc/calloc without NULL check
    • Search for integer overflow in size calculations
    • Search for missing bounds checks on array access
    • Search for unchecked fwrite()/fread() return values
    • Search for direct SQLite/file I/O calls in runtime bindings (bypass of hl_cap_*)
  3. Review Public API

    • Check all public functions in headers (hl_* prefix)
    • Verify NULL checks on pointer parameters
    • Verify bounds checks on size parameters
  4. Check Resource Management

    • Every _init()/_create() has matching _free()/_close()
    • Error paths free allocated resources
    • No memory leaks on early returns
    • SQLite statements finalized on error paths
    • QuickJS/Lua contexts cleaned up on error paths
  5. Check Capability Boundaries

    • JS/Lua bindings only access resources through hl_cap_* functions
    • Path validation enforced before every filesystem operation
    • SQL always parameterized
    • Sandbox restrictions in place (no eval, no io/os libs)
  6. Detect Dead Code

    • Compile with -Wunused flags
    • Find unused static functions
    • Find unused variables and parameters
    • Flag commented-out or #if 0 code blocks
  7. Check Build Hardening

    • Sanitizers available in debug build
    • Stack protection in production build
    • Warning flags comprehensive
  8. Generate Report Format as markdown table with findings, severity, file:line, and suggested fix.

Report Format

markdown
1## C Audit Report: Hull 2 3**Date:** YYYY-MM-DD 4**Files Scanned:** N 5**Issues Found:** N (Critical: N, High: N, Medium: N, Low: N) 6 7### Critical Issues 8 9| # | File:Line | Issue | Current Code | Suggested Fix | 10|---|-----------|-------|--------------|---------------| 11| C1 | src/cap/hull_cap_db.c:42 | Buffer overflow | `strcpy(buf, src)` | `snprintf(buf, sizeof(buf), "%s", src)` | 12 13### High Issues 14... 15 16### Medium Issues 17... 18 19### Low Issues 20... 21 22### Recommendations 231. ...

Fix Mode (--fix)

When --fix is specified:

  1. Generate the audit report first
  2. For each fixable issue, apply the transformation
  3. Rebuild (make)
  4. Re-run tests (make test)
  5. Report any test failures or new warnings

Auto-fixable Issues:

  • strcpy -> snprintf with buffer size
  • sprintf -> snprintf with buffer size
  • atoi -> strtol with validation
  • Missing NULL checks (add early return)
  • Missing malloc return check (add NULL check)
  • Integer overflow in size calc -> calloc or overflow check
  • Missing size_t casts in size calculations
  • Unused local variables (remove)
  • Unused static functions (remove)

NOT Auto-fixable (require manual review):

  • Logic errors
  • Resource leaks in complex control flow
  • Capability boundary violations
  • Sandbox escape paths
  • Architectural changes

Related Skills

Looking for an alternative to c-audit or building a Categories.community AI Agent? Explore these related open-source MCP Servers.

View All

widget-generator

Logo of f
f

widget-generator is an open-source AI agent skill for creating widget plugins that are injected into prompt feeds on prompts.chat. It supports two rendering modes: standard prompt widgets using default PromptCard styling and custom render widgets built as full React components.

149.6k
0
Design

chat-sdk

Logo of lobehub
lobehub

chat-sdk is a unified TypeScript SDK for building chat bots across multiple platforms, providing a single interface for deploying bot logic.

73.0k
0
Communication

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
Communication

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
Communication