Back to skill

Security audit

Config Manager - 配置管理器

Security checks for vulnerabilities and agentic risk

Overview

This is a small C configuration-management helper that does only disclosed, user-directed config loading and saving, though its parser and serializer need hardening before security-sensitive use.

Reasonable to install for review or experimentation. Before using this in production or security-sensitive software, harden empty-value parsing, integer range checks, key/value escaping, and path handling; do not load attacker-controlled configuration files or save untrusted strings without validation.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (3)

T09 · Insecure Skill Coding Practices

Warning
Location
code.c:186
Finding

Undefined Behavior When Parsing an Empty Configuration Value

Content
View full analysis
value && (*end == '\n' || *end == '\r' || *end == ' ')) *end-- = '\0'; ``` ### Technical Analysis When a configuration entry has an empty value and no trailing newline, such as `key=` at the end of a file, `value` points to an empty string and `strlen(value)` returns zero. The expression below consequently attempts to form a pointer one byte before the beginning of the `value` object: ```c char* end = value + strlen(value) - 1; ``` Forming this out-of-bounds pointer is undefined behavior under the C memory model, even if the following loop condition normally prevents it from being dereferenced. Compiler optimizations, runtime instrumentation, or platform-specific behavior may therefore produce unpredictable results. The same condition can occur after leading spaces or tabs are skipped if no other characters remain and the line has no newline terminator. ### Attack Path 1. An attacker gains control over a configuration file accepted by an application using this library. 2. The attacker places an empty assignment such as `key=` as the final line without a newline. 3. The application calls `config_load_file()` on that file. 4. The parser calculates `value + 0 - 1`, forming an invalid pointer. 5. The application encounters undefined, compiler-dependent behavior and may terminate, particularly under memory-safety instrumentation or hardened runtime environments. ### Impact Assessment The direct impact is availability loss or unpredictable configuration parsing in the process loading the malicious file. The flaw ...[truncated 275 chars]
Remediation
View remediation
0) { char last = value[value_len - 1]; if (last != '\n' && last != '\r' && last != ' ' && last != '\t') { break; } value[--value_len] = '\0'; } ``` Additionally: - Define and test the intended behavior for empty configuration values. - Add regression tests for `key=`, `key= `, empty final lines, and files both with and without trailing newlines. - Compile tests with AddressSanitizer and UndefinedBehaviorSanitizer. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
code.c:199
Finding

Unchecked Integer Conversion and Unsafe Narrowing

Content
View full analysis
Remediation
View remediation
#include errno = 0; char* endptr = NULL; long val = strtol(value, &endptr, 10); if (endptr != value && *endptr == '\0' && errno != ERANGE && val >= INT_MIN && val <= INT_MAX) { if (!config_add_int(cm, key, (int)val)) { /* Handle insertion failure. */ } } else { /* Reject the invalid integer or treat it according to an explicit policy. */ } ``` Further hardening should include: - Rejecting out-of-range values rather than silently treating them as strings when a key is expected to be numeric. - Supporting per-key minimum and maximum constraints. - Propagating parse errors to the caller instead of returning success for partially invalid files. - Testing `INT_MIN`, `INT_MAX`, adjacent out-of-range values, `LONG_MIN`, `LONG_MAX`, and extremely long numeric strings. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
code.c:233
Finding

Configuration Injection Through Unescaped Serialization

Content
View full analysis
key); switch (item->type) { case CONFIG_STRING: fprintf(f, "%s\n", item->value.str_value); break; ``` ### Technical Analysis Keys and string values are written directly to a line-oriented `key=value` file without escaping or rejecting structural characters. In particular, newline and carriage-return characters in a key or value can create additional configuration records. For example, a string value equivalent to: ```text ordinary admin=true ``` is serialized as multiple lines. When the generated file is later loaded, `admin=true` is interpreted as an independent Boolean configuration entry. Keys containing line breaks or `=` characters can produce similar structural ambiguity. The issue is not a format-string vulnerability because the untrusted data is passed through `%s`. It is a data-format injection vulnerability caused by the absence of encoding and validation at the serialization boundary. ### Attack Path 1. An attacker supplies a key or string value to an application that exposes `config_add_string()` to untrusted input. 2. The supplied value contains a newline followed by an attacker-selected assignment, such as `\nadmin=true`. 3. The application calls `config_save_file()`. 4. The serializer writes the embedded newline literally, creating an additional configuration line. 5. The generated file is subsequently loaded through `config_load_file()` or consumed by another compatible parser. 6. The injected assignment is interpreted as a distinct configuration setting. 7. Depending on insertion order and key selection, the injected setting may add or replace a security-relevant option. ### Impact Assessment An attacker may manipulate the contents and meaning of saved configuration files, introduce unauthorized settings, or ov ...[truncated 542 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (3)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

SQP-3 applies to all file types and covers language or locale policy violations. The document forces a single language for all instructions and descriptions, with no user opt-in, alternative language, or stated region-specific justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code's natural-language comments, title, and demo output are presented only in Chinese, with no indication that the skill is region-specific or that users can opt into another language. The policy requires avoiding forced language or locale constraints unless they are optional or clearly justified.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This is a markdown file, so SQP-2 applies to omissions in user-facing warnings. The changelog explicitly states the skill supports configuration file loading/saving, but the document does not warn users that it may read from or write to configuration files, which could affect user data or project settings.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.