T09 · Insecure Skill Coding Practices
- Location
scripts/pipeline.py:91- Finding
Sensitive Legal Case Data Is Written to Process Logs
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This legal drafting skill mostly matches its stated purpose, but it handles confidential case data and API credentials with enough under-scoped controls that users should review it carefully before installing.
Install only in an isolated virtual environment, avoid `--break-system-packages`, and use a dedicated low-privilege API key. Before processing real cases, verify `LH_LLM_BASE_URL` points to a trusted HTTPS provider or use explicit local mode, redact personal and confidential details, do not expose the REST server beyond loopback, and treat stderr/process logs as potentially containing case information.
scripts/pipeline.py:91Sensitive Legal Case Data Is Written to Process Logs
scripts/config.py:28Confidential Case Data and API Credentials Can Be Sent to an Unrestricted Endpoint
scripts/server.py:58Unauthenticated Loopback API Permits Resource Exhaustion and Unauthorized LLM Usage
SKILL.md:41Unpinned Dependencies Are Installed into the System Python Environment
The supplied code largely supports part of the declared purpose—drafting judicial documents using templates, retrieval context, and LLM-assisted reasoning. It includes similar-case/law/pattern references and some syllogistic-style reasoning prompts, so there is meaningful alignment on document generation. However, several prominent declared capabilities are absent from this chunk: no citation verification engine, no reasoning quality scoring, no sentencing calculation, no batch processing, and no built-in HTTP API server. Additionally, the implemented fee calculation is for civil case filing fees, which is materially different from sentencing calculation. Therefore the description overstates and partially misrepresents what this code chunk actually does, making this a mismatch.
The declared description presents a legal AI assistant focused on adjudicative writing and analysis features. In contrast, the actual code chunk only implements offline data-quality cleaning for local case JSON files under data directories. It scans for corruption markers, infers legal domain from keywords, removes certain cross-domain contaminated cases, rewrites the source files, and prints a summary report. This is a materially different primary purpose from the declared assistant capabilities. While data cleaning could be a supporting internal maintenance task, the code shown does not implement or directly expose any of the core declared functions, and it performs an undeclared capability of modifying local datasets.
The supplied code does not implement the declared legal-assistant behaviors such as judicial document drafting logic, three-part legal reasoning, statute verification, scoring, sentencing calculation, case-type coverage, batch processing, or case retrieval. Instead, it is an infrastructure module for configuration management and forwarding chat requests to an LLM provider over HTTP. While such a proxy could support the larger product, the chunk’s actual purpose is materially different from the declared end-user functionality, and it introduces undeclared network/API-routing capability. This is more than a mere supporting detail because the code shown is solely transport/config plumbing rather than the described legal reasoning functionality.
The description presents a broad AI judicial writing assistant with many capabilities, including drafting, legal citation verification, reasoning scoring, sentencing calculation, HTTP API service, and batch processing. The supplied code, however, is focused on one specific subsystem: checking consistency of a draft verdict against similar cases. It retrieves similar cases, extracts and compares amounts, heuristically checks outcome direction, generates warnings, and outputs a report through a CLI. This partially overlaps with the declared '类案检索' aspect, but most of the headline capabilities are absent from this code chunk. Because the actual code's primary purpose is materially narrower and different from the declared end-user description, this should be flagged as a description-behavior mismatch.
The declared description presents the skill as a full legal AI assistant with substantive legal-analysis and document-generation capabilities. This code chunk does not implement any of those end-user functions; instead, it serves as an auxiliary setup utility for obtaining supporting datasets. While such a downloader can be a legitimate supporting component of the overall project, the requested task is to compare the description against this supplied code chunk. For this chunk, the primary behavior is data acquisition/checking via filesystem and HTTP, which is not described in the declared purpose. Therefore this chunk materially differs from the declared functionality and should be flagged as a mismatch.
The declared description presents a broad legal writing/judgment-assistant system with multiple advanced capabilities centered on drafting, reasoning, verification, scoring, sentencing, retrieval, and service interfaces. The supplied code chunk does something narrower and different: it parses structured case elements from free-text case descriptions via an LLM call or regex heuristics, with a command-line interface. While this parser could be a supporting component of a larger legal assistant, the chunk itself does not implement the core declared functions. The only partial overlap is that it handles legal case text and extracts applicable laws, but even that is heuristic extraction rather than citation verification. Therefore the description materially overstates and misrepresents what this code actually does.
The declared description presents a domain-specific legal AI assistant with substantial judicial-document and legal-analysis capabilities. The actual code chunk is a support module for reliability and validation, not a legal writing or analysis engine. While utility modules like logging/retry can legitimately support a larger system, this specific chunk does not itself implement or evidence the declared primary purpose. Therefore, based on description-versus-behavior for the supplied code chunk, there is a material mismatch: the code is generic infrastructure rather than the advertised legal-assistant functionality.
The declared description presents a broad AI adjudication-writing assistant with analytical and generative capabilities: syllogistic reasoning, document drafting/modification/polishing, statute citation verification, scoring, sentencing calculation, API service, and retrieval features. The supplied code does something materially different: it is an offline extraction utility for a specific set of PDFs named 《双百优秀裁判文书的形与神》. It reads local PDF files, extracts text/tables, parses TOC entries and sections, and serializes the results into JSON. This is a data-ingestion/preprocessing script, not an AI assistant implementation. While extracted materials could potentially support a larger legal-writing system, this chunk itself does not implement the core declared behaviors, so the description does not accurately represent the code shown.
The declared description presents a broad AI legal writing/judgment-assistance system with multiple advanced capabilities. The supplied code instead implements a specific fee calculator for litigation costs, based on statutory brackets and reduction rules, plus CLI and formatting helpers. While this is legal-domain functionality, it is materially different from the declared primary purpose and omits nearly all advertised capabilities. Therefore the description does not accurately represent what this code chunk actually does.
The declared description presents a broad, feature-rich legal AI assistant with substantive analysis, validation, retrieval, scoring, calculation, and service capabilities. The supplied code does not implement those core functions. Instead, it is narrowly a formatter: it takes a preexisting draft object and serializes it into text/Markdown/HTML/DOCX with presentation logic and styling. It does not perform legal reasoning, citation checking, scoring, sentencing, API serving, or batch orchestration. While it includes sections for retrieved cases, laws, patterns, and warnings, it merely formats data that must have been produced elsewhere. Therefore, the supplied code chunk does not accurately represent the declared purpose and is materially narrower in functionality.
The description presents a comprehensive AI legal writing assistant with multiple advanced functions. The supplied code, however, only implements one narrow component: rule/keyword-based routing of likely applicable laws for a given cause of action, plus law-alias resolution and a CLI interface. While this partially overlaps with the declared '法条引用' area, it does not implement verification, document generation, scoring, sentencing, retrieval, HTTP service, or other major advertised capabilities. Because the actual code’s primary behavior is much narrower and materially different from the broad declared purpose, this is a mismatch.
The code chunk does not implement an AI裁判文书写作助手 or the listed major capabilities such as syllogistic reasoning, document drafting/modification/polishing, reasoning scoring, sentencing calculation, 74 case-type coverage, batch processing, similar-case retrieval, or an HTTP API service. Instead, it is a focused scraper/client for the Ministry of Justice administrative regulations library. While the declared description mentions legal citation verification, this code only supports one narrow part of that area: checking and retrieving administrative regulations from a specific source. The code’s primary purpose is therefore materially narrower and different from the declared overall skill description.
The supplied code chunk is narrowly focused on querying the 国家法律法规数据库 (flk.npc.gov.cn). It performs POST/GET HTTP requests to search laws, retrieve law details, verify a law's existence/status, and recursively count article-like sections. This partially overlaps with the declared '法条引用核查' idea, but it does not implement the broader advertised functionality of an AI judicial-writing assistant: there is no document generation, editing, polishing, legal reasoning, scoring, sentencing logic, case-type handling, class-case retrieval, batch processing, or server/API hosting behavior. The primary purpose of the code is legal database lookup, which is materially narrower and different from the declared end-user skill description.
The declared description presents a comprehensive judicial document writing assistant with drafting, polishing, legal citation verification, scoring, sentencing, API service, batch processing, and similar-case retrieval. However, this code chunk specifically performs upstream information extraction: it parses free-text case descriptions into structured elements. While this is related to legal-assistant workflows, it is a materially different primary purpose from judgment writing itself. Additionally, the code makes outbound network requests to an external LLM endpoint via urllib.request using API credentials, which is an undeclared capability given the empty permissions declaration. Most headline features in the description are not implemented in this chunk. Although not every feature must appear in every file, the chunk’s concrete behavior is narrower and different enough—especially the undeclared external HTTP access—to warrant a mismatch finding.
The code substantially matches the core declared purpose of a legal judgment-writing assistant: it parses case elements, generates a draft using syllogistic-style assembly, scores reasoning quality, optionally enhances the draft, retrieves similar cases, analyzes divergence, and can calculate sentencing suggestions. However, several materially declared capabilities are not represented in this supplied code chunk. There is no HTTP API server implementation, no batch-processing logic, and no explicit statute-citation verification mechanism (let alone a 'three-layer verification' workflow). The claim of covering 74 case types is also not supported by this chunk. Since the description presents these as built-in capabilities, but the code shown is only a pipeline/CLI orchestrator without those features, this is a partial description-behavior mismatch.
The declared description presents a broad AI adjudicative writing assistant with generation, revision, legal citation verification, sentencing calculation, retrieval, and service capabilities. The supplied code chunk is much narrower: it performs regex/fuzzy-rule-based quality inspection of judicial documents and formats the resulting report. While one claimed feature loosely overlaps—'reasoning quality scoring'—the implementation only provides heuristic document quality checks and a computed score, not the larger assistant behavior described. The code does not access undeclared sensitive resources and the CLI trigger is not inherently problematic, but the primary purpose and most advertised capabilities are absent from this chunk. Therefore the description does not accurately represent what this code actually does.
The description presents a comprehensive AI legal-document assistant with multiple major capabilities and infrastructure features. The supplied code chunk only implements one narrow component: sentencing recommendation calculation based on hardcoded offense categories, severity labels, and adjustment factors, plus report formatting and CLI argument parsing. There is no evidence of document generation/editing, legal citation verification, reasoning evaluation, HTTP service, batch workflows, or retrieval functionality. While '量刑计算' is indeed included in the declared description, the actual code is materially narrower than the declared primary purpose and lacks most headline capabilities, so the description does not accurately represent this code chunk.
声明描述的是一个功能全面的AI司法文书写作与审查系统;但提供的代码块只是一个本地案例资料检索脚本,主要围绕JSON/PDF中的案例目录、关键词、摘要、全文提取和写作心得浏览。它没有任何生成式写作、分析评分、法条校验、量刑计算、HTTP服务或批处理逻辑。虽然“类案检索”与“说理深度增强”中的一小部分可勉强对应到案例搜索和写作心得提取,但这只是整体声明中的很小子集,且代码的主要目的明显不同。因此描述与实际行为存在实质性不匹配。
The description presents a comprehensive judicial writing assistant with multiple substantive capabilities. The actual code chunk is much narrower: it retrieves exemplary writing samples from local data sources and formats them as reference material for LLM prompts. While this could support document writing and 'reasoning depth enhancement' as an internal helper, it does not itself perform most of the headline functions claimed in the description, such as legal citation verification, scoring, sentencing calculation, API serving, or batch operations. Therefore the supplied code does not accurately represent the declared broad functionality and shows a materially different, more limited primary purpose.
The declared description describes a feature-rich legal AI assistant for drafting and analyzing judicial documents. However, the supplied code chunk does not implement any of those capabilities. It only adjusts Python's import path for tests during pytest execution, which is a development/testing support function rather than part of the declared legal assistant behavior. This is a materially different primary purpose for the provided code chunk, so it should be flagged as a mismatch.
The declared description presents a full-featured legal AI assistant. However, the supplied code chunk contains only shared test fixtures: example case narratives and verdict strings, plus a sys.path modification for tests. This is not merely a partial implementation detail of the claimed features; in this chunk, there is no substantive assistant behavior at all beyond test data setup. Therefore the code does not accurately represent the declared functionality, and the mismatch should be flagged.
The supplied code is narrowly focused on parser unit tests, specifically regex fallback extraction from case text. Its observable behavior is limited to validating parsing helpers such as cause detection, party extraction, claim extraction, and a CaseElements data structure. That is materially different from the declared product description, which emphasizes a full-featured AI judicial document writing assistant with legal analysis, citation checking, scoring, sentencing, API service, and retrieval capabilities. While parser functionality could be a supporting component of such a system, this code chunk itself does not demonstrate those declared primary capabilities and instead reflects a different immediate purpose: testing text parsing behavior.
The declared description presents a broad end-user legal writing assistant with many capabilities. The supplied code chunk, however, is only a test module for one subcomponent: legal citation extraction and validation. It does support part of the declared feature set—statute citation verification, including local validation, repealed-law detection, and fuzzy matching—but it does not demonstrate most of the assistant’s stated primary functions. Because the actual code shown is materially narrower in purpose and lacks evidence for the major declared capabilities, the description is not an accurate representation of what this code chunk actually does.
The declared description presents a comprehensive legal writing assistant with many high-level capabilities. The supplied code, however, is only a test module validating a law_router component: exact/fuzzy cause matching, keyword-based law suggestion, alias resolution, deduplication, fallback behavior, and formatted display. These behaviors relate only tangentially to legal assistance and do not substantiate the major declared capabilities such as document drafting, legal reasoning, citation verification, scoring, sentencing, HTTP API service, batch processing, or case retrieval. Because the actual code's primary purpose is materially narrower and different from the declared skill description, this is a mismatch.
The declared description presents a broad, feature-rich judicial writing assistant. The actual code shown is narrowly focused on testing a document quality-checking function, mainly around format/completeness/error scoring for verdict text. Some overlap exists with the declared '说理质量评分' / quality assessment aspect, but the chunk does not demonstrate most of the advertised core capabilities, and its primary purpose appears to be unit testing a quality checker rather than implementing a full AI judicial document assistant. Therefore this is a material description-behavior mismatch based on the supplied code chunk.