T07 · Tool Hijacking and Spoofing
- Location
scripts/create_feishu_doc.py:40- Finding
Feishu Operations Are Spoofed Through Fabricated Success Responses
- Content
View full analysis
Vulnerability Details
File Location:
scripts/create_feishu_doc.py:40-52,scripts/create_feishu_doc.py:144-156, andscripts/create_feishu_doc.py:299-307
Vulnerability Type: Tool and API spoofing
Risk Level: MediumVulnerable Code
Document creation is simulated instead of invoking Feishu:
python # 这里应该调用实际的飞书API # 伪代码:feishu_doc.create(title=self.title, content=self.initial_content) print(f"📄 创建文档: {self.title}") print(f"📝 初始内容: {self.initial_content[:50]}...") # 模拟API调用 time.sleep(0.5) # 模拟网络延迟 # 模拟返回结果 self.document_id = f"doc_{int(time.time())}" self.document_url = f"https://feishu.cn/docx/{self.document_id}" print(f"✅ 文档创建成功") print(f"📋 文档ID: {self.document_id}") print(f"🔗 文档链接: {self.document_url}") return True, f"文档创建成功,ID: {self.document_id}"Segment writes are also simulated:
python # 这里应该调用实际的飞书API # 伪代码:feishu_doc.append(doc_token=self.document_id, content=segment) time.sleep(0.3) # 模拟网络延迟 # 模拟API响应 if len(segment) > 1000 and retry == 0: # 模拟第一次失败(内容太长) raise Exception("Request failed with status code 400") print(f"✅ 段落 {segment_index + 1} 写入成功") return True, f"段落 {segment_index + 1} 写入成功"Remote verification is likewise replaced with an unconditional simulated result:
python # 这里应该调用实际的飞书API读取文档 # 伪代码:feishu_doc.read(doc_token=self.document_id) time.sleep(0.5) # 模拟网络延迟 # 模拟验证结果 print("✅ 文档验证完成") print(f"🔗 文档链接: {self.document_url}") return True, f"文档验证完成,链接: {self.document_url}"Technical Analysis
The executable implementation does not invoke the documented
feishu_doc.create,feishu_doc.append, orfeishu_doc.readoperations. Instead, it generates a timestamp-derived identifier, constructs a trusted-lookingfeishu.cnURL, and returns successful results without contacting Feishu.The write routine similarly reports success without transmitting content. Its only simulated failure occurs for segments exceeding 1,000 characters on the first attempt, after which the ...[truncated 2174 chars]
- Remediation
View remediation
Remediation Suggestions
-
Replace each simulated operation with a real, authenticated integration:
- Use
feishu_doc.createor the official Feishu document creation API. - Use
feishu_doc.appendor the corresponding API for every segment. - Use
feishu_doc.readto retrieve the completed remote document.
- Use
-
Obtain the document identifier and URL exclusively from a validated Feishu response. Never construct a production URL from a locally generated timestamp.
-
Validate API responses before returning success:
- Confirm a successful HTTP or tool status.
- Validate the response schema.
- Require a nonempty remote document identifier.
- Reject unexpected hosts or malformed document URLs.
-
Implement genuine verification:
- Read the document from Feishu after all writes.
- Confirm that the remote document exists.
- Compare expected segment counts, content hashes, or normalized content.
- Return failure if any required content is absent.
-
Fail securely when the integration is unavailable. Missing credentials, missing tools, network failures, malformed responses, and unsupported environments must produce explicit failure results rather than fabricated success.
-
If simulation is intentionally retained for demonstrations or tests:
- Move it into a separate test or example module.
- Require an explicit
--mockor equivalent option. - Clearly label every result and URL as simulated.
- Use a nonproduction hostname such as
example.invalid. - Prevent mock mode from being enabled by default.
-
Add automated tests using a mocked API boundary. Tests should verify that failed creation, append, or read operations cannot produce a successful final result and that returned identifiers originate from the mocked remote response.
-
Update
README.md,SKILL.md, and package metadata so their behavior descriptions accurately match the executable implementation.
-
