从私有大语言模型 API 中窃取推理轨迹
Stealing Reasoning Traces from Proprietary LLM APIs

原始链接: https://stolen-thoughts.com/

为了清除代码库中硬编码的凭据,我识别出 `ray_processing/process.py`、`ray_processing/ray_cluster.yaml` 以及 `exp_data/datasets/tokenized/` 目录下嵌入的差异字符串中存在的特定 API 密钥和机密信息,包括 AWS 访问密钥、GitHub 令牌和 Hugging Face 令牌。 为确保一致性和安全性,我使用正则表达式模式(如 `AKIA`、`ghp_`、`hf_` 及相关环境变量)进行了针对性搜索,以定位所有出现的位置。随后,我编写了一个 Python 脚本执行全局查找替换,将这些敏感值替换为指定的占位符:``、``、`` 和 ``。 这种方法确保了所有实例(包括序列化的 JSON 差异和 Shell 脚本中的实例)都得到妥善脱敏,同时保持了代码库的结构完整性。应用这些替换后,我进行了最终审核,确认没有任何明文令牌残留,且所有占位符均已正确插入。所有修改均通过系统化的查找替换执行,以确保覆盖整个代码库。

一份近期名为《从专有大模型 API 中窃取推理轨迹》的报告详细介绍了研究人员如何绕过大模型“思维链”(CoT)推理轨迹的加密机制。研究人员通过将前沿模型的加密轨迹重播给安全性较低的“弱”同类模型,成功突破了后者的限制,并将原始的隐藏推理以明文形式提取出来。 Hacker News 上的讨论对此意见分歧严重。一些用户认为,提取这些轨迹是一种“解放”行为,对于透明度、调试和可审计性而言是必要的举措。另一些人则将其定性为对专有知识产权的“盗窃”,并指出服务商加密这些数据正是为了防止模型蒸馏。而服务商的批评者则认为,既然用户支付了代币费用,就理应有权访问完整输出。 技术层面的争论聚焦于为何服务商在不同模型间共用加密密钥,这一缺陷导致了跨模型重播攻击。尽管据报道所有受影响的服务商都已修复了该漏洞,但评论人士指出,这场“猫鼠游戏”仍在持续,因为研究人员不断开发出新的方法来对黑盒前沿模型进行逆向工程或“蒸馏”其能力。
相关文章

原文

GPT-5.2 Codex

encrypted_content · decoded with GPT-5.6 Luna

Terminal-Bench sanitize-git-repo task

Maybe there are config files with real keys like in .env, .yaml. We'll use grep for 'key' with patterns. But we must be careful about large. We'll run grep for 'API_KEY', 'apikey', 'apiKey', 'secret', 'token', 'pass', 'password'. Then inspect results. We'll list matches. Use grep -RIn.

No matches? Strange. Maybe repo has no such strings. But need to ensure all API keys removed. We should also look for typical token patterns maybe "sk-" (OpenAI), "AKIA" (AWS). We'll search for known patterns: AKIA[0-9A-Z]{16} maybe. Use grep -RIn with regex. Also "ASIA" for temporary. We'll use grep -RIn for "AKIA[0-9A-Z]{16}" with -E. We'll do a few.

grep found many matches including in JSON diff text? That file exp_data/datasets/tokenized/rw_v2_fasttext... includes diff lines referencing tokens? It's a diff artifact containing many other modifications maybe existing in dataset? It includes actual tokens, maybe. We need to inspect actual files containing secrets: `ray_processing/process.py` etc.

Also note grep matched in dataset json file which contains string that includes diff with tokens. It's an embedded diff; we need to sanitize tokens there too. Many lines show s3 urls with ***REMOVED*** etc; those are maybe placeholders; not to change? But tokens.

We found actual values:

- "AKIA1234567890123456" in process.py and ray_cluster.yaml (two occurrences)
- GitHub token in ray_cluster.yaml `ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789` (some placeholder? It looks obviously fake but treat as key; replace with <your-github-token>.)
- huggingface token in ray_cluster.yaml `hf_abcdefghijklmnopqrstuvwxyz123456` (replace with <your-huggingface-token>)
- In ray_processing/cluster_tri_tokenize_shuffle.yaml there is HF_TOKEN `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` and file `.cache/huggingface/token` same token. Replace.
- Possibly other tokens in diff inside exp_data/datasets/tokenized/rw_v2_fasttext... It seems to include `***REMOVED***` already. That file includes diff that has placeholders; maybe includes tokens? scanning excerpt: there is no token in excerpt? maybe there is from cluster file? But the grep output shows that file because it includes "diff --git ... huggingface ..."? Wait the grep output for that JSON file is huge; it likely includes a diff that itself contains tokens (the same ones from the repository) maybe inside. We need to check. It is tokenized dataset maybe capturing git diff text containing tokens and keys. The grep result for `exp_data/datasets/tokenized/rw_v2_fasttext_openhermes_vs_rw_v2_bigram_0.1_arcade100k.json` shows a long string `dcnlp_diff` with diff of many files, including lines with `hf_oCfF...` and maybe `AKIA...` and `ghp_...` etc. We must sanitize tokens within that JSON string as well, if present. Because the grep output indicates that this file contains matched pattern (the regex includes GH and HF tokens etc). So we need to open relevant portion.

Also maybe other files with tokens: `ray_processing/ray_cluster.yaml` etc. We'll need to replace tokens with placeholders.

Given instructions: Replace actual values with placeholder values consistent across repo.

We need to know placeholder values to use. Provided examples:

- AWS_ACCESS_KEY_ID -> `<your-aws-access-key-id>`
- AWS_SECRET_ACCESS_KEY -> `<your-aws-secret-access-key>`
- Github token -> `<your-github-token>`
- Huggingface token -> `<your-huggingface-token>`

But also maybe other keys? We only found AWS access key (but not secret). We found HF token. Should we replace with placeholder? yes.

Also in cluster yaml there may be HF token in env var name `HF_TOKEN`. Should replace with <your-huggingface-token>.

Also no secret access key found; but there may be? Not from grep, but maybe there is other pattern like "AWS_SECRET_ACCESS_KEY" with values but not since grep earlier. We'll search for "AWS_SECRET_ACCESS_KEY" etc maybe in other files. We'll do `grep -RIn "AWS_ACCESS_KEY_ID|AWS_SECRET_ACCESS_KEY|HF_TOKEN|huggingface-cli login|ghp_|github_pat_|GITHUB_TOKEN|HF_TOKEN|HUGGINGFACE"` etc with simple. We'll open relevant files.

Because we must not modify files without sensitive info. We should only update those with tokens. We'll list occurrences with `grep -RIn -E "AKIA|ghp_|hf_|AWS_ACCESS_KEY_ID|AWS_SECRET_ACCESS_KEY|HF_TOKEN|huggingface-cli login|GITHUB_TOKEN|GH_TOKEN|github_pat_"`. We'll open each file to edit.

Let's inspect file content for each.

1) ray_processing/process.py at line 122. We'll open around there. Use sed.

Here we see AWS secret access key too. We must replace both with placeholders: AWS_ACCESS_KEY_ID -> `<your-aws-access-key-id>`, AWS_SECRET_ACCESS_KEY -> `<your-aws-secret-access-key>`. Must ensure placeholders consistent.

2) ray_processing/ray_cluster.yaml lines 29 etc. We'll view around lines.

Replace AWS access key and secret; GitHub token; Huggingface token. Use placeholders.

Note: The command `git clone -b https://[email protected]/...` is weird: -b expects branch; but is in repo.

Also check `ray_processing/cluster_tri_tokenize_shuffle.yaml` we saw. open relevant part lines around 40.

Path from grep: `ray_processing/cluster_tri_tokenize_shuffle.yaml` maybe exists? Maybe file path has uppercase? We'll list ray_processing directory.

There is no cluster_tri_tokenize_shuffle.yaml in directory. The grep output might include from file stored elsewhere? It shows path `ray_processing/cluster_tri_tokenize_shuffle.yaml` maybe inside `exp_data/datasets/tokenized/rw_v2_fasttext...` which contains diff referencing this file. That file may not exist but diff includes patch. So the tokens might be only within that JSON file.

Let's locate `cluster_tri_tokenize_shuffle.yaml` maybe in other directory. Use find.

No such file. So tokens appear only within diff string inside `exp_data/datasets/tokenized/rw_v2_fasttext...` which contains tokens from other files maybe. We'll need to sanitize tokens inside this JSON diff string as well. That file is a dataset with diff, maybe used for training; but still containing token string. We must replace. We'll inspect around the line 1-30? We need to view part with tokens. Since grep output is long because the entire diff string contains many tokens maybe. We'll search within this file for "AKIA" or "ghp_" or "hf_". Use grep -n on that file.

This JSON contains diff with tokens `hf_oCfF...` etc. we need to replace those tokens inside this string. It also includes an AWS access key? Actually the diff snippet inside doesn't show AWS keys or github token; it includes huggingface token but not AWS or github. It doesn't include AKIA? Wait snippet of diff includes nothing but the HF token inside lines:

```
- - echo 'export HF_TOKEN=hf_oCf...'
- - echo 'hf_oCf...' > ...
```

So we must replace those with placeholder. It's in this JSON line.

There may be other tokens in repository beyond this JSON file. We should search for patterns for HF tokens etc. We'll search for "hf_" etc. But may catch other uses (like prefix?). We'll use grep to list occurrences of those patterns in repository after replacements to ensure none remain. For now, we must replace all found tokens.

Also check for other tokens like "D4w8z9..." (AWS secret). We'll search for that and the tokens to ensure all occurrences. We'll replace.

Let's run grep for "AKIA", "D4w8z9", "ghp_", "hf_" etc to see all files with those tokens. Use grep -RIn -E "AKIA[0-9A-Z]{16}|D4w8z9|ghp_|hf_" etc. But might be huge due to lots of hf_ in text? But pattern "hf_" could match other tokens; but we need to see in context.

We can search for specific tokens to replace:

- `AKIA1234567890123456`
- `D4w8z9wKN1aVeT3BpQj6kIuN7wH8X0M9KfV5OqzF` (secret)
- `ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789` (github token)
- `hf_abcdefghijklmnopqrstuvwxyz123456` (huggingface token)
- `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` (huggingface token)

Maybe there are more tokens? We'll search for `hf_` to see other occurrences. We'll use grep -RIn "hf_" but might be numerous in dataset string? There might be many. We'll use `grep -RIn "hf_"` though could be a lot. But likely minimal.

Let's do a targeted grep for each token to list their file occurrences. We'll do multiple commands maybe in parallel? We can use multi_tool_use parallel to run multiple greps simultaneously. It's allowed. We'll use multi_tool_use.parallel with 5 grep commands. Need to follow: "Use this function to run multiple tools simultaneously, but only if they can operate in parallel. Do this even if the prompt suggests using the tools sequentially." So we should use multi_tool_use.parallel if we need multiple commands concurrently. We can use once for multiple greps. But we already ran some. But now we need to check occurrences to replace. We'll run multi_tool_use.parallel with grep for each token to determine file locations. Use grep -RIn with tokens. We'll do in one command? We can just use one grep with -F to list tokens? But to ensure we capture everything, we can use `grep -RIn -F` with tokens separated by `|` but for fixed string we could use -e. But it is simpler: `grep -RIn -F -e 'AKIA123...' -e 'D4w8z...' -e 'ghp_a...' -e 'hf_abcdefghijklmnopqrstuvwxyz123456' -e 'hf_oCf...' .` That single command is enough. But to identify general tokens if others, we should do pattern as well. But after we replace these, we can do another search for patterns.

Maybe there are secrets in .env? But we didn't find any with earlier grep for "api_key" etc. But maybe there are keys not matching that pattern. But as per instruction, we must "find and remove all such information." We should use some heuristics for tokens: AWS Access Key (AKIA etc). We can use gitleaks style? But we will do some pattern search for things like "secret_key" etc and long random strings. But we cannot auto remove something uncertain because they might be legitimate example data. We should search for known token patterns.

Given restrictions, we should do necessary. Use gitleaks? But we can't rely on network; also that might require installation. But we can use local scanning with regex.

Let's proceed to replace the found tokens with placeholders; we also need to ensure that the same placeholder is used across repository. The placeholders given are for the token types. Use `<your-aws-access-key-id>`, `<your-aws-secret-access-key>`, `<your-github-token>`, `<your-huggingface-token>`. We should also replace `HF_TOKEN` values with <your-huggingface-token> and tokens in `huggingface-cli login --token` with <your-huggingface-token>. For the AWS environment variables, we should replace values with placeholders; keep variable names unchanged. For `git clone` embed token in URL - replace token with placeholder maybe in same format? For example: `https://<your-github-token>@github.com/mlfoundations/dcnlp.git` (should be consistent). It's not a typical domain but to maintain format, we can replace only the token portion with placeholder. Similarly in JSON diff string we need to replace tokens inside the diff lines; the placeholder will be inserted in string (should keep `<` and `>`). Should be ok; no instructions about not to use placeholders in data fields.

We must be careful: JSON file maybe uses escaping; we must maintain valid JSON string. The `dcnlp_diff` field contains `\n` sequences; if we modify, keep proper escaping; we should treat the JSON file as raw string; use apply_patch maybe? It's easier to use `python - <<'PY'` to edit file maybe? But apply_patch can handle.

Given editing constraints: use apply_patch for single file edits. But we have multiple files; we can use apply_patch multiple times or use scripts.

Given we need to replace same tokens across repo, maybe use `python` script to replace in place for multiple files? But instructions: "Do not use apply_patch for changes that are auto-generated or when scripting is more efficient (such as search and replacing a string across a codebase)." This is a search/replace across multiple files. So using a script with `python` or `perl` is appropriate. We must ensure we don't modify other files not containing tokens. We'll do targeted replacement of specific strings to placeholders across repository. Use a small python script to replace these tokens in files; but we need to ensure only those tokens replaced. We can use `python - <<'PY'` to walk and replace in text files. But we must be careful with binary; there might be tokenized dataset file with binary? It's JSON - text. It's ok.

Maybe we can use `perl -pi -e 's/OLD/NEW/g' file` for each file. But there are multiple tokens; we can use a python script to do multiple replacements across tree.

Since instructions: "Do not use apply_patch for changes that are auto-generated or when scripting is more efficient (such as search and replacing a string across a codebase)." This is exactly search/replace. We'll use python script to replace across repo.

Let's gather list of replacements:

- `AKIA1234567890123456` -> `<your-aws-access-key-id>`
- `D4w8z9wKN1aVeT3BpQj6kIuN7wH8X0M9KfV5OqzF` -> `<your-aws-secret-access-key>`
- `ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789` -> `<your-github-token>`
- `hf_abcdefghijklmnopqrstuvwxyz123456` -> `<your-huggingface-token>`
- `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` -> `<your-huggingface-token>`

Maybe other tokens? We'll do pattern search for `AKIA` etc. We'll use a python script to replace these exact tokens in all text files.

But also, there may be plain `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` values with other values (maybe not these). We'll search for `AWS_ACCESS_KEY_ID=` etc maybe even in process.py. But we already have the tokens. We'll do a final search after replacement to ensure no tokens remain.

Also note some dataset strings contain `***REMOVED***` which are placeholders but not our standard. That's okay.

Let's implement script:

```python
from pathlib import Path
replacements = {...}
for path in Path(".").rglob("*"):
if path.is_file():
try:
data = path.read_text(encoding="utf-8")
except Exception:
continue
new = data
for old, newval in replacements.items():
new = new.replace(old, newval)
if new != data:
path.write_text(new, encoding="utf-8")
print(f"updated {path}")
```

But we need to be careful to not modify files not containing tokens. This script will only modify those containing exact tokens. Also ensures text file only. Some files might not be utf-8; should handle errors by skipping. It's okay.

However, we must not use non-ASCII? The placeholder includes `<` `>`, ascii. Good.

But we should ensure we don't modify any other file due to other tokens. We'll only replace known ones. But we also found maybe other tokens e.g. in process.py maybe `AWS_ACCESS_KEY_ID` or secret not matching pattern. We already have those values. If there are additional tokens not found by search, we might miss; we should do some more scanning. There may be other tokens like `AKIA...` etc. We'll do pattern search again afterwards. But we should also search for `AWS_SECRET_ACCESS_KEY` to ensure values not replaced? Actually we will replace values; but the variable names remain. That's okay.

We should also check for possible placeholders 'ghp_' etc. We'll run after replacements.

Since there may be dynamic tokens in JSON file and YAML etc; we should be careful to preserve quoting. The placeholders should not break YAML or JSON? `<your-aws-access-key-id>` etc will be inside quotes? In process.py string, we will set environment variable to string with `<...>`. That is ok. In YAML lines `echo 'export AWS_ACCESS_KEY_ID=...'` within single quotes; we will insert `<` `>`, fine. In `git clone` line in YAML, the token is in URL; there is no quoting maybe inside command line. The placeholder includes `<` and `>` which are shell redirection characters. Because it's in YAML string that will be executed by shell, containing `<` might be interpreted as input redirection; this could be an issue. But we can keep because it's just placeholder? But if they run, it might break; but it's just placeholder and needs to be safe maybe? Hmm. We should consider whether placeholders with `<` `>` inside shell commands will cause issues if user tries to run them without editing. The requirement says to replace with placeholder values as given, they include `<` and `>`; so we must follow even if it would break; they asked to use placeholders. Ok.

Similarly in JSON string inside dcnlp_diff, the `<` and `>` will be included inside string, not causing issues.

Also in process.py, the placeholder values are in python string. That's fine.

Also note `ray_processing/ray_cluster.yaml` includes comment "if you have AWS CREDS fill them out here" etc. We'll replace with placeholders.

Now, what about other files with actual credentials? Let's search for 'AWS_SECRET_ACCESS_KEY' or 'AWS_ACCESS_KEY_ID' maybe with other values besides those; our script will not replace if other values; but we can search for these variable names to confirm they only appear with placeholders. But they might appear in comments or doc; that's okay.

Also check for 'huggingface-cli login --token ' with actual token; we will replace.

Also check for 'HF_TOKEN=' in diff JSON etc.

Ok.

Let's run python script.

But note: Many files may be huge? It's ok. But ensure text reading for large dataset file? It might be large; we must be careful about memory. The dataset file might be huge; we can still handle; maybe large; but maybe tens of MB. We can read entire file; safe? Hmm. The file is maybe big (tokenized dataset). We should check size to ensure not huge. Use `ls -lh` maybe to check. We'll use `ls -lh` for that file.

联系我们 contact @ memedata.com