T09 · Insecure Skill Coding Practices
- Location
main.py:78- Finding
Unvalidated User Input Enables AliMail Directory Filter Manipulation
- Content
View full analysis
Vulnerability Details
File Location:
main.py, lines 78-85
Vulnerability Type: Filter injection through unescaped user input
Risk Level: Mediumpython url = f"{self.base}/v2/users" params = {"filter": f"(name=*{name})", "size": 10} headers = {"Authorization": f"Bearer {token}"} try: res = requests.get(url, params=params, headers=headers, timeout=10)Technical Analysis
The externally supplied
nameargument is inserted directly into a structured AliMail filter expression:python f"(name=*{name})"The code performs no validation or escaping of wildcard characters, parentheses, or other metacharacters recognized by the remote filter parser. Consequently, input such as a wildcard can broaden the search beyond a specific employee. Crafted delimiters may also alter the filter expression if the AliMail API accepts compound or nested filter syntax.
URL encoding performed by
requestsdoes not prevent this issue because it only ensures safe HTTP transport; the remote API decodes the parameter before interpreting its filter syntax.Attack Path
- An attacker or unauthorized caller gains access to the
search_alimail_userSkill tool. - The attacker supplies a wildcard or crafted filter expression as the
nameparameter. main.pyembeds the value directly into thefilterquery parameter.- The request is authenticated using the configured AliMail service credential and sent to
/v2/users. - The AliMail service evaluates the broadened or manipulated filter under the service account's permissions.
- The Skill returns matching employee names, email addresses, employee numbers, and the overall match count.
- Repeated requests may allow broader enumeration of the enterprise directory.
Impact Assessment
Successful exploitation may disclose internal employee directory information beyond the intended lookup, including names, email addresses, employee numbe ...[truncated 536 chars]
- An attacker or unauthorized caller gains access to the
- Remediation
View remediation
Remediation Suggestions
- Validate the
nameparameter against a restrictive allowlist appropriate for employee names. Reject wildcard characters, parentheses, control characters, and filter operators. - Escape all filter metacharacters according to the official AliMail filter grammar before constructing the expression.
- Prefer an AliMail API parameter that accepts a literal name rather than exposing raw filter syntax, if such an endpoint is available.
- Enforce reasonable minimum and maximum input lengths to prevent broad one-character searches and resource abuse.
- Consider exact matching by default and expose fuzzy matching only through a controlled server-side transformation.
- Apply authorization and rate limiting at the Skill boundary to restrict directory searches to approved users and reduce enumeration risk.
- Return only fields required by the caller. Avoid exposing
employeeNoor the total match count unless operationally necessary. - Add tests covering wildcard-only input, parentheses, logical operators, malformed filters, empty input, and unusually long values.
- Validate the
