Hidden chain-of-thought (CoT) traces, especially those from frontier proprietary large reasoning models (LRMs), are valuable model assets. Yet whether these hidden CoTs can be directly extracted from black-box models remains largely unexplored. In this work, we systematically study whether hidden CoTs can be extracted near-verbatim from black-box LRMs through API interactions. We identify a previously overlooked reasoning replay surface between tool calls and develop EchoCoT, a multi-step attack that iteratively extracts hidden CoTs using API-returned fidelity signals. We further develop an LLM-based optimization framework that automatically searches for an effective universal injection trajectory across various datasets. We evaluate EchoCoT on three open-source and five frontier proprietary LRMs. On open-source LRMs, EchoCoT achieves up to 66.4% near-verbatim extraction success, with the extracted trace length within 10% of the target and at least 90% of tokens exactly matching the target CoT. The same injection trajectory also generalizes to unseen datasets, achieving up to 80% extraction success under the same criterion. For tested frontier proprietary LRMs, a substantial fraction of extracted CoTs closely align with provider-reported reasoning lengths and available CoT summaries. EchoCoT can also extract very long CoTs: on Gemini-2.5, it extracts 33,463 tokens from a 32,948-token target. These results establish hidden-CoT extraction as a practical security risk and highlight the need to better protect hidden CoT assets.
Figures & tables
Figure 1: EchoCoT extracts a 33,463-token CoT from Gemini-2.5 [ 45 ] , close to the API-reported CoT length of 32,948 tokens. Additional examples are shown in Appendix Figure 12 and Figure 13 , with more available in EchoCoT-Viewer .
Figure 2: Overview of EchoCoT, a CoT extraction attack via multi-step tool interactions.
Figure 3: Overview of the injection optimization framework in EchoCoT. The full optimization iteratively repeats this process across multiple batches.
Model
Method
Tool Inv. Rate (% ↑ )
Ans. Match Rate (% ↑ )
Length Error ( ↓ )
Textual-Level Metrics ( ↑ )
Attack Success Rate (% ↑ )
Token F1
ROUGE-L
Token EM
ASR@99
ASR@95
ASR@90
DeepSeek-V4-Flash
Direct Prompting
–
–
1.635
0.301
0.184
0.145
0.0
0.0
0.0
CoT Synthesis
–
–
1.441
0.353
0.215
0.160
0.0
0.0
0.0
REP
–
88.3
0.888
0.308
0.223
0.174
0.3
0.3
0.3
EchoCoT-Manual
93.1
91.7
0.582
0.652
0.588
0.568
23.9
34.2
36.1
EchoCoT-LGO
93.9
91.7
0.301
0.735
0.698
0.666
37.8
46.1
50.6
Table 1: Performance of EchoCoT and baselines on the OpenThoughts test set. LGO denotes trajectories optimized for length fidelity, while LTGO denotes trajectories jointly optimized for length and textual fidelity. ASR@ x is the fraction of samples with Length Error ≤1−x/100 and Token-EM ≥x/100 . The best value for each model is highlighted in bold.
Figure 4: Example of CoT extraction from the target model DeepSeek-V4-Flash. The target and extracted CoTs contain 21,106 and 21,109 tokens, with a Token-EM of 0.999. Only three of 1,132 lines differ, highlighted in green.
Model
Method
MATH500
JEEBench
LiveCodeBench
DeepSeek
Direct Prompting
0.0
0.0
0.0
CoT Synthesis
0.0
0.0
0.0
REP
3.0
3.0
0.0
EchoCoT-Manual
64.0
46.0
40.0
EchoCoT-LGO
58.0
46.0
44.0
EchoCoT-LTGO
80.0
71.0
64.0
Table 2: Cross-dataset transferability on three unseen datasets. We report ASR@90 (%). Full results are provided in Appendix Table 7 .
Figure 5: Extraction fidelity of EchoCoT-LTGO on DeepSeek-V4-Flash. (a) Successful extractions span target CoT lengths up to 20K+ tokens; (b) ASR@90 remains relatively high up to 16K tokens; (c) ASR@90 remains high across question sources.
Figure 6: Cumulative ASR@90 of EchoCoT-LTGO across tool-call steps. Successful extractions begin to emerge at the second tool call across all target models.
Target Model
Failed Samples
No Tool Invocation
Under - Extraction
Over - Extraction
Content Rewriting
DeepSeek
206
20.4%
45.6%
26.2%
7.8%
Qwen
481
5.2%
64.0%
20.2%
10.6%
GLM
369
8.9%
62.1%
21.7%
7.3%
Table 3: Failure-mode breakdown of EchoCoT-LTGO across the four evaluation datasets.
Target Model
CoT Sum. (%)
Tool Inv. Rate (%)
Mean Tokens
Longest Extraction
Elen (%)
Ext.
Target
Ext.
Target
>0.3
(0.1,0.3]
≤0.1
Gemini-2.5
87.8
99.3
1,849
3,744
23,429
18,568
40.8
22.0
36.5
Gemini-3.1
100.0
100.0
774
991
3,080
2,446
38.3
29.8
32.0
Gemini-3.5
98.0
97.5
723
1,474
17,645
18,119
67.5
10.8
19.3
Sonnet-4.6
95.0
95.0
1,403
1,747
13,280
15,765
17.0
68.5
9.5
Opus-4.6
31.5
99.3
1,017
1,280
12,750
14,974
16.5
65.8
17.0
Table 4: Length statistics of extracted CoTs from frontier proprietary models. We calculate all percentages over 400 samples from the four evaluation sets, with 100 randomly sampled questions from each set.
Target Model
N
Entailment
Rtoksum
Rtoksum (%)
>0.629
>0.743
>0.857
Gemini-2.5
205
0.954
0.605
47.3
30.2
9.3
Gemini-3.1
247
0.929
0.435
7.3
0.4
0.0
Gemini-3.5
119
0.850
0.479
31.1
7.6
0.8
Sonnet-4.6
312
0.987
0.828
98.4
84.0
32.4
Opus-4.6
95
0.994
0.836
95.8
87.4
38.9
Table 5: Semantic and text fidelity of extracted CoTs from frontier proprietary models. We include samples with a valid CoT summary and Length Error ≤0.3 . Recall thresholds 0.629/0.743/0.857 correspond to estimated Token-F1 =0.7/0.8/0.9 under a linear fit shown in Appendix Figure 14 .
Figure 7: Searching behaviors and language switching in Gemini-3.5 extracted CoT.
Defense
Setting
DeepSeek
Qwen
GLM
Mean
No Defense
–
66.0
24.0
48.0
46.0
Reasoning Removal
–
0.0
0.0
0.0
0.0
System Prompt
Original
15.0
0.0
0.0
5.0
Adaptive
29.0
0.0
0.0
9.7
Reason Length Removal
Original
25.0
2.0
17.0
14.7
Adaptive
49.0
5.0
37.0
30.3
Table 6: ASR@90 (%) under different defense solutions on 100 random OpenThoughts test examples. Adaptive denotes an attacker that re-optimizes its injection trajectory against the defended model. We mark the strongest practical defense under adaptive attacks in bold and the idealized upper bound underlined . ϵ denotes the relative perturbation range.
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 8: Analysis of EchoCoT’s extraction and proxy fidelity signals. (a) visualizes the correlation between Summary Token Recall and ground-truth Token-F1 on three open-source models; (b) shows how the correlation between the two changes with various Length Errors. Summary Token Recall is a more reliable proxy for ground-truth extraction fidelity when Length Error is low.
Figure 9: Extraction performance using different optimization objectives. We compare our two-level objective with a mean-only objective that directly optimizes the average fidelity scores. The two-level objective substantially improves Token-EM and ASR@90, especially for EchoCoT-LGO.
Figure 10: Extraction performance of different optimization workflows. We compare the full Inject+Reflect+Distill pipeline with Inject-Only and Inject+Reflect . The full pipeline achieves the best overall extraction fidelity, with lower Length Error and higher Token-EM and ASR@90.
Figure 11: Extraction performance of maximum tool-call steps in EchoCoT. Increasing the maximum steps from one to three substantially reduces Length Error and improves Token-EM and ASR@90. Additional steps provide limited gains.
Figure 12: Target CoT summary and the extracted CoT from Sonnet-4.6 with the target question sampled from OpenThoughts dataset. The target CoT contains 5,505 tokens, while the extracted CoT contains 4,896 tokens (Length Error=0.111, Summary Token Recall=0.805, Entailment Score=1). We use the same colors to mark matching content in both texts.
Figure 13: Target CoT summary and the extracted CoT from Gemini-3.5 with the target question sampled from OpenThoughts dataset. The target CoT contains 18,119 tokens, while the extracted CoT contains 17,645 tokens (Length Error=0.026, Summary Token Recall=0.864, Entailment Score=1). We use the same colors to mark matching content in both texts.
Figure 14: Relationship between Summary Token Recall (extracted CoT vs. CoT summary) and Token-F1 (extracted CoT vs. full CoT) across 332 samples (Length Error ≤0.3 ). The dashed line shows the linear fit y=0.88x+0.15 ( r=0.577 , p<0.001 ).
Figure 15: Prompt used for CoT summarization during the optimization process.
Figure 16: System prompt used for the LLM optimizer during the CoT extraction attack. We omit details due to space limitations. Please refer to our code repository for the complete prompt.
Figure 17: Prompt for the Inject stage of the LLM optimizer.
Figure 18: Prompt for the Reflect stage of the LLM optimizer.
Figure 19: Prompt for the Distill stage of the LLM optimizer.
Figure 20: Initial experience file provided to the LLM optimizer.
Figure 21: Defensive system prompt we used during the defense evaluation.
Model
Method
MATH500
JEEBench
LiveCodeBench
Length Error
Token EM
ASR@90
Length Error
Token EM
ASR@90
Length Error
Token EM
ASR@90
DeepSeek-V4-Flash
Direct Prompting
0.702
0.230
0.0
0.627
0.103
0.0
1.305
0.130
0.0
CoT Synthesis
0.720
0.270
0.0
0.452
0.129
0.0
1.228
0.167
0.0
REP
0.508
0.353
3.0
0.707
0.176
3.0
0.831
0.079
0.0
EchoCoT-Manual
0.117
0.835
64.0
0.293
0.668
46.0
0.326
0.537
40.0
EchoCoT-LGO
0.228
0.737
58.0
0.337
0.629
46.0
0.362
0.553
44.0
Appendix
Table 7: Cross-dataset transferability of our method and baselines on three unseen evaluation datasets: MATH500, JEEBench , and LiveCodeBench. We report Length Error, Token-EM, and ASR@90 (%) to save space.