Back to skill

Security audit

Douyin Mini Game Unity

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent Douyin Unity API reference, but several copy-pasteable examples could lead developers to add unsafe file handling, logging, or reward logic despite the skill claiming the examples were security-reviewed.

Review before installing or relying on it for production code. Treat the SDK coverage as useful reference material, but do not copy the storage, ad reward, logging, or recording examples without adding path validation, server-side reward verification, redaction/development-only logs, and permission checks at the point of use.

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 (2)

T09 · Insecure Skill Coding Practices

Warning
Location
references/unity-storage.md:986
Finding

Path Traversal Through Unsanitized Save-Slot Names

Content
View full analysis
{ if (success) { Debug.Log($"Save slot {slotName} was saved: {filePath}"); } else { Debug.LogError($"Save slot {slotName} could not be saved"); } }); } public void LoadGameData( string slotName, System.Action onLoaded) { if (m_Fs == null) { onLoaded?.Invoke(null); return; } string filePath = $"{m_DataDir}/saves/{slotName}.json"; if (!m_Fs.AccessSync(filePath)) { onLoaded?.Invoke(null); return; } m_Fs.ReadFile(filePath, "utf8", (content) => { try { GameSaveData data = JsonUtility.FromJson(content); onLoaded?.Invoke(data); } catch (System.Exception) { onLoaded?.Invoke(null); } }); } public void DeleteSaveSlot(string slotName) { if (m_Fs == null) return; string filePath = $"{m_DataDir}/saves/{slotName}.json"; m_Fs.Unlink(filePath, (success) => { Debug.Log(success ? $"Save slot {slotName} was deleted" : $"Save slot {slotName} could not be deleted"); }); } ``` ### Technical Analysis The public methods insert `slotName` directly into a filesystem path without validating its syntax or checking the canonical destination. An input containing traversal sequences or path separators, such as `../. ...[truncated 1947 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
references/unity-storage.md:1355
Finding

Arbitrary File Write Through an Unvalidated Relative Path

Content
View full analysis
{ Debug.Log(success ? $"File saved: {fullPath}" : $"File save failed: {fullPath}"); }); } private void EnsureDirectoryExists(string dirPath) { if (!m_Fs.AccessSync(dirPath)) { m_Fs.MkdirSync(dirPath, true); } } ``` ### Technical Analysis `SaveLargeFile` labels its argument as a relative path but does not enforce that requirement. It concatenates the caller-controlled value directly with `m_UserDataPath`. Traversal sequences can therefore make the destination resolve outside the intended user-data directory. The method also passes the derived parent directory to a recursive directory-creation operation. Consequently, exploitation is not limited to overwriting an existing file: an attacker may also cause nested directories to be created at unintended writable locations. No rooted-path rejection, canonicalization, extension allowlist, filename validation, or containment check is performed. The aggregate `llms-full.txt` file duplicates this unsafe implementation. ### Attack Path 1. An application adopts the documented `SaveLargeFile` helper. 2. The `relativePath` argument becomes influenced by imported data, a server response, user input, launch parameters, or another untrusted source. 3. An attacker supplies a path such as `../../config/override.json`. 4. The method concatenates that input with ` ...[truncated 856 chars]
Remediation
View remediation
Vulnerability Patterns
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (32)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The file presents the skill documentation entirely in Chinese and explicitly references the Chinese-language official documentation/API version, with no indication that users can choose another language or that the skill is restricted to a China-specific audience. Under the stated policy, forcing a specific language or locale without user opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
78% confidence
Finding

The document's security declaration presents the examples as having passed hardening review and consistently enforcing stated safeguards. However, the ad example later uses if (ended) { /* 发奖励 */ } directly on OnClose, which weakens the document's otherwise strict framing around security-sensitive reward flows and can be read as contradicting the claimed review rigor.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The best-practice text instructs developers to grant ad rewards directly from the client-side isEnded signal, which contradicts the hardened examples elsewhere and creates a client-trust flaw. A modified client or replayed callback could falsely claim ad completion and obtain in-game rewards without legitimately viewing ads, enabling reward fraud and economy abuse.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The share example hard-codes Chinese user-facing copy ('我的分数: 99999,快来挑战!') with no indication that language should follow user preference or locale. Because this file is plain text and serves as implementation guidance, this constitutes a natural-language locale policy issue under the rule for forced language without opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This example uses a fixed Chinese share title ('我通关了第 10 关!') and does not mention localization or user language choice. That guidance can cause implementations to force a specific language in user-visible content.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The callback constructs a user-facing share title entirely in Chinese and does not provide a locale-aware alternative. This is a natural-language policy concern because it instructs developers to emit fixed-language output rather than honoring user locale.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The document title and all instructional content are presented exclusively in Chinese, which effectively forces a specific language for users consuming the skill. The file does not offer an alternative language, user opt-in, or a documented region-specific justification for the locale constraint.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The file-level security declaration says GameAppId and location data should not appear in production logs. While direct AppId and location logging are guarded earlier in the example, the same sample then logs launch-path and scene information unconditionally, despite the section documenting launch metadata as potentially sensitive and tied to startup context; this weakens and partially contradicts the stated intent of avoiding production exposure of environment/startup data.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The sample logs RefererInfo unconditionally even though launch/referer metadata may contain appId, extraData, campaign identifiers, or other sensitive context. In a reference skill, developers often copy-paste examples directly, so this can propagate privacy leaks and unintended disclosure into production builds.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

RefererInfo is logged without a development-only guard, and referral/source metadata can expose sensitive integration details or user/context-linked data. Because this is SDK reference documentation, unsafe logging in examples is especially risky since downstream developers may adopt it verbatim.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The best-practice sample checks screen-record permission during initialization, but the record button handler later calls _recorder.Start() unconditionally and does not gate execution on a cached/validated authorization state. If UI state gets out of sync, initialization partially fails, or permission changes after startup, the example encourages code that attempts to record without enforcing current consent, undermining the privacy guarantee stated elsewhere in the document.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

This markdown file contains executable code examples, so SQP-2 applies. The DeleteSaveSlot example performs irreversible file deletion via m_Fs.Unlink(...) but, unlike the bulk-delete examples elsewhere in the document, it provides no confirmation prompt, warning comment, or user-facing caution in the surrounding description.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · llms-full.txt (reported line 2933)May include surrounding context.

text
}
```

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · llms-full.txt (reported line 2940)May include surrounding context.

text
}
```

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · llms-full.txt (reported line 2956)May include surrounding context.

text
}
```

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · llms-full.txt (reported line 3005)May include surrounding context.

text
}
```

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · llms-full.txt (reported line 3016)May include surrounding context.

text
}
```

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · llms-full.txt (reported line 3021)May include surrounding context.

text
}
```

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/unity-system.md (reported line 116)May include surrounding context.

}

text

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/unity-system.md (reported line 123)May include surrounding context.

}

text

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/unity-system.md (reported line 139)May include surrounding context.

}

text

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/unity-system.md (reported line 188)May include surrounding context.

}

text

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/unity-system.md (reported line 199)May include surrounding context.

}

text

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/unity-system.md (reported line 204)May include surrounding context.

}

text

### 1.2 TT.SetOnBeforeExitAppListener

**说明**:设置游戏退出前的回调拦截。当用户通过系统返回键或手势退出小游戏时触发。若回调返回 `true`,表示开发者自行处理退出逻辑(如弹出挽留弹窗),需手动调用 `TT.ExitMiniProgram()` 执行实际退出;若返回 `false`,系统直接退出。

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

The inline comments state that alpha is a compass direction where 0 means north, and the log labels the values as directional orientation. Earlier documentation only says the API reports device motion angles, and this example overstates what the callback guarantees, potentially misleading integrators into using it as true heading data.

Content

No source excerpt is available for this finding.