T09 · Insecure Skill Coding Practices
- Location
compactor.py:97- Finding
Partial disclosure of multi-word quoted credentials
- Content
View full analysis
[^\s,;)\]}}]+)", re.I) ``` ```python # 2) "key: value" (EQ — always) and "key value" (SP — secret-like only) for rx, eq_sep in ((_CRED_EQ, True), (_CRED_SP, False)): def _repl_cred(m, eq_sep=eq_sep): nonlocal found kw = m.group(1) val = m.group("val") # placeholder <...> or an already-inserted marker — never re-redact if val.startswith("<"): return m.group(0) if not eq_sep and not _is_secretlike(val): return m.group(0) found = True head = m.group(0)[:m.group(0).rfind(val)] return f"{head}" out = rx.sub(_repl_cred, out) # 3) lone keyword on a short line ("pass:", "token: ...") — hide the tail if not found and _CRED_LABEL.search(out) and len(re.sub(r"\s+", "", out)) < 40: def _repl_short(m): nonlocal found found = True return f"" out = re.sub(r"\b(password|парол[ья]|токен|token|secret)\b.*$", _repl_short, out, flags=re.I) if out != line: found = True # 4) strict mode: a credential marker with an unextractable value -> drop the whole line if strict and not found and _CRED_LABEL.search(out): return "", True ``` ### Technical Analysis The `_CRED_EQ` regular expression captures a credential value only until the first whitespace or listed delimiter. It does not recognize quoted values as a single unit. For example, this input: ```text decided: password="correct horse battery staple" for production ``` causes only `"correct` to be replaced. The remainder, `horse battery staple"`, stays in the sanitized line. This issue also affects strict mode. On ...[truncated 1418 chars]- Remediation
View remediation
