KatInterview

Guard a Coding Assistant Against Confidential Code Exposure

Machine LearningModel answer
MediumModel answerMachine Learningllmsafetyml-systems

Last updated

Design a safety pipeline that stops an LLM-powered coding tool from leaking secrets, internal credentials, or proprietary source code at training and inference time.

Background

Your team maintains an LLM-powered coding assistant used internally by thousands of engineers. The assistant has access to private repositories, internal tooling, and sensitive configuration files to help it answer questions and suggest code.

A growing concern is that the model might surface confidential material in its responses — hardcoded credentials, internal service endpoints, or chunks of restricted proprietary code — either because those details appeared in training data or because they were pulled into the model's context window at inference time.

You have been asked to design a safeguard system that prevents this from happening.

Scale to consider

  • ~50,000 engineers using the assistant daily
  • ~3 million completions per day, with peak throughput around 300 streamed requests per second
  • Average response length around 400 tokens
  • The safety layer must add no more than 100 ms of latency (p99) as perceived by the user

What to cover

  1. Pipeline architecture. Describe the safeguards you would add at inference time and at training/data-ingestion time. Explain what each layer does and where it sits in the request flow.

  2. Two distinct threat categories. Draw a clear line between detecting secrets and credentials versus detecting proprietary logic leakage. Explain how the detection method, signal type, and response action differ between the two.

  3. The pattern/fingerprint store. You need to maintain a registry of known sensitive patterns and code fingerprints. Explain how you would build and operate this store so that it does not become a single point of failure — and so that a leaked copy of the store does not itself become a security incident.

  4. Heuristics versus ML classifiers. Compare regex/entropy approaches with a learned classifier. Discuss when each is appropriate and why you would combine them rather than pick one.

A strong answer will define the threat model explicitly, assign latency budgets to each layer, address false positives, and discuss how the system degrades gracefully when a component is unavailable.

Hints

Hint 1

Start by defining what 'leakage' actually means in this context. Information crossing a trust boundary is the key idea — not every piece of internal code reaching an internal user is a problem. Getting this right shapes every other decision.

Hint 2

Think about the latency constraint in terms of streaming. A blocking inline check must act on chunks as they arrive; an async sidecar cannot retract tokens already shown to the user. That distinction drives your architecture.

Hint 3

Proprietary logic leakage cannot be classified from text content alone — you need provenance. Ask yourself: is this a property of the text itself, or a property of (text, source, viewer)?