Research


Research interests

My research asks why language models fail to act on what they know about safety, and what to do about it. I work on three steps: find where safe behavior breaks down inside the model, repair it without retraining, and prevent unsafe behavior from being learned in the first place.

  • Diagnosis: how safety breaks during training. How refusal and other safe behavior erode across pretraining and post-training (SFT, DPO and RL), measured inside the model with tools such as the refusal direction.
  • Intervention: repair without retraining. Probes and steering vectors that locate where a model’s safe knowledge gets lost and push the decision back. Insecure code generation is my first worked case, and attention-head repair of an arithmetic error is another.
  • Prevention: open-weight risk. Which training data teaches an unsafe behavior, whether data attribution or filtering can stop it, and how to test safeguards against attackers who hold the weights. In code models, unlearning can hide knowledge instead of deleting it.
  • Measurement: safety numbers you can trust. Red-teaming methods, judges and benchmarks, and why one model gets different safety numbers from different evaluations.

Earlier work, which I still build on, studied how AI coding assistants affect the security of the code people write (Lost at C) and how to defend against prompt injection.

I received my PhD from NYU and was advised by Siddharth Garg and Brendan Dolan-Gavitt, and a member of the EnSuRe Research Lab.

Publications

You can also find my papers on Google Scholar.

Figure from Surgical Repair of Insecure Code Generation in LLMs: From Mechanistic Diagnosis to Deployment-Ready Intervention
Gustavo Sandoval, Brendan Dolan-Gavitt, Siddharth Garg
arXiv preprint, 2026
Figure from Suppression is not Deletion: Adversarial Probes Recover Unlearned Knowledge in Code LLMs
Dhairyasheel Patil, Gustavo Sandoval
ICML 2026 Workshop on Memorization in Foundation Models (MemFM), poster
Figure from Even Heads Fix Odd Errors: Mechanistic Discovery and Surgical Repair in Transformer Attention
Gustavo Sandoval
arXiv preprint, 2025
Figure from Early Approaches to Adversarial Fine-Tuning for Prompt Injection Defense: A 2022 Study of GPT-3 and Contemporary Models
Gustavo Sandoval, Denys Fenchenko, Junyao Chen
arXiv preprint, 2025
Figure from Lost at C: A User Study on the Security Implications of Large Language Model Code Assistants
Gustavo Sandoval*, Hammond Pearce*, Teo Nys, Ramesh Karri, Siddharth Garg, Brendan Dolan-Gavitt (*equal contribution)
32nd USENIX Security Symposium (USENIX Security 23)

Collaborations

I’m always interested in collaborating with other researchers in AI safety and interpretability. Feel free to reach out if you’re working on related problems.