- Location
- vendor/xhs_api/static/xhs_rap.js:420
- Finding
- Opaque Decoded Bytecode Executes Inside the Xiaohongshu Signing Runtime<![CDATA[
## Vulnerability Details
**File Location**: `vendor/xhs_api/static/xhs_rap.js:420 onward`
**Execution Location**: `vendor/xhs_api/xhs_utils/xhs_util.py:62-65`
**Vulnerability Type**: Obfuscated executable component with an unauditable trust boundary
**Risk Level**: Medium
### Vulnerable Code
The signing JavaScript contains a custom interpreter that decodes an embedded Base64-like payload and executes its instruction sequence:
```javascript
y=(function(B){
if(!B)return"";
for(var Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),
A=B.length,E=0,C=[];E<A;){
var g=Q.indexOf(B.charAt(E++)),
H=Q.indexOf(B.charAt(E++)),
I=Q.indexOf(B.charAt(E++)),
c=Q.indexOf(B.charAt(E++)),
J=g<<2|H>>4,
k=(15&H)<<4|I>>2,
w=(3&I)<<6|c;
C.push(String.fromCharCode(J)),
64!=I&&C.push(String.fromCharCode(k)),
64!=c&&C.push(String.fromCharCode(w))
}
return function(B){
for(var Q=[],A=B.length,E=0,E=0;E<A;E++){
var C=B.charCodeAt(E);
if((C>>7&255)==0)Q.push(B.charAt(E));
else if((C>>5&255)==6){
var g=B.charCodeAt(++E),H=(31&C)<<6,I=63&g,c=H|I;
Q.push(String.fromCharCode(c))
} else if((C>>4&255)==14){
var g=B.charCodeAt(++E),J=B.charCodeAt(++E),
H=C<<4|g>>2&15,I=(3&g)<<6|63&J,c=(255&H)<<8|I;
Q.push(String.fromCharCode(c))
}
}
return Q.join("")
}(C.join(""))
})(E.b).split("").reduce(function(B,Q){
return(!B.length||5==B[B.length-1].length)&&B.push([]),
B[B.length-1].push(-1+Q.charCodeAt()),B
},[]);
```
The decoded instruction array is then interpreted:
```javascript
_garp_2846=function(B){
for(var Q=0;Q<B.length;){
var A=B[Q];
Q=(0,G[A[0]])(A[1],A[2],A[3],A[4],Q,y,B)
}
}
```
The Python code compiles the complete script
...[truncated 2126 chars]
- Remediation
- <![CDATA[
## Remediation Suggestions
1. Replace the obfuscated virtual-machine implementation with a readable signing implementation.
2. Record the exact upstream repository revision and cryptographic hash from which each vendored JavaScript file was obtained.
3. Do not advise users to synchronize signing files from an unpinned upstream branch.
4. Require code review and reproducible hash verification for every update.
5. Run the signing runtime in a dedicated sandbox with no inherited secrets, no network access, and no access to user credential directories.
6. Expose only the minimum signing inputs and output through a narrow inter-process interface.
7. Add runtime monitoring that rejects unexpected filesystem, process, or network operations.
8. Document that the component is reverse-engineered executable code and make the related Xiaohongshu integration opt-in.
]]>