CodeCipher: Learning to Obfuscate Source Code Against LLMs

Yalan Lin, Chengcheng Wan, Yixiong Fang, Xiaodong Gu
10/8/2024
cs.CL

No confident code implementation found for this paper.

Abstract

While large code language models have made significant strides in AI-assisted coding tasks, there are growing concerns about privacy challenges. The user code is transparent to the cloud LLM service provider, inducing risks of unauthorized training, reading, and execution of the user code.

Show full abstract

In this paper, we propose CodeCipher, a novel method that perturbs privacy from code while preserving the original response from LLMs. CodeCipher transforms the LLM's embedding matrix so that each row corresponds to a different word in the original matrix, forming a token-to-token confusion mapping for obfuscating source code. The new embedding matrix is optimized by minimizing the task-specific loss function. To tackle the challenge of the discrete and sparse nature of word vector spaces, CodeCipher adopts a discrete optimization strategy that aligns the updated vector to the nearest valid token in the vocabulary before each gradient update. We demonstrate the effectiveness of our approach on three AI-assisted coding tasks including code completion, summarization, and translation. Results show that our model successfully confuses the privacy in source code while preserving the original LLM's performance.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{lin2024codecipher,
  title  = {CodeCipher: Learning to Obfuscate Source Code Against LLMs},
  author = {Yalan Lin and Chengcheng Wan and Yixiong Fang and Xiaodong Gu},
  year   = {2024},
  eprint = {2410.05797},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.05797v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.05797.svg)](https://codeofpaper.com/paper/2410.05797)

Discussion