逐日AI

面试题库

共 328 题,当前筛选 1 题。

标签
还有 359 个标签
#api-design9#coding-agent9#distributed-systems8#multi-agent8#rag8#chunking7#debugging7#pipeline-design7#structured-output7#agent-loop6#mcp6#operations6#prompt-injection6#sse6#tool-calling6#tool-design6#context5#context-engineering5#deployment5#embeddings5#hybrid-search5#message-bus5#scheduling5#system-prompt5#agentic-rag4#behavioral4#client4#concurrency4#consistency4#framework-design4#ingestion4#prompt-engineering4#rate-limiting4#retrieval4#routing4#trade-offs4#abstention3#agents-sdk3#caching3#communication3#context-window3#cost-control3#data-quality3#failure-modes3#image-generation3#interview-prep3#langgraph3#latency3#llm-as-judge3#llm-basics3#long-context3#model-migration3#model-routing3#orchestration3#ordering3#progressive-disclosure3#prompt-basics3#prompt-caching3#protocol3#provider-abstraction3#ranking3#recall3#redis-streams3#responses-api3#resume3#retry3#runtime3#scalability3#skills3#state-management3#statelessness3#subagents3#timeline3#versioning3#workflow-engine3#access-control2#agent-design2#async-task2#auth2#checkpointing2#citation-verification2#citations2#claude-md2#code-review2#compaction2#context-rot2#contextual-retrieval2#cost-tradeoff2#data-modeling2#database2#distribution2#fallback2#ffmpeg2#golden-set2#grounding2#interview-process2#long-term-memory2#media-pipeline2#memory2#multi-hop2#multi-tenancy2#oauth2#prioritization2#project-storytelling2#prompt-techniques2#query-rewriting2#react2#refusal2#reproducibility2#rerank2#retrieval-quality2#retrospective2#scripts2#sharding2#state-machine2#tool-permissions2#tooling2#tools2#tracing2#transport2#tts2#ux2#vector-database2#verification2#workflow2#agent-basics1#agent-quality1#agent-sdk1#agents-md1#altitude1#analytics1#approvals1#architecture-review1#async1#atomicity1#attention-budget1#av-sync1#backoff1#bi-encoder1#bm251#budget-control1#build-vs-buy1#cancellation1#candidate-selection1#capacity-planning1#career1#chain-of-thought1#ci1#circuit-breaker1#claude-code1#cli-design1#client-integration1#cloud1#compression1#configuration1#confused-deputy1#consistent-hashing1#content-hash1#content-safety1#context-assembly1#context-compression1#context-management1#coreference1#correctness1#cost-accounting1#cost-analysis1#cost-optimization1#cross-encoder1#cross-model1#customer-support1#dag1#decision-making1#decomposition1#degradation1#deliberate-practice1#design1#diagnostics1#dimensions1#docker1#documentation1#embedding-migration1#encoding1#engineering-judgement1#engineering-tradeoffs1#error-propagation1#escalation1#eval1#event-driven1#evidence1#failure-analysis1#fairness1#faithfulness1#fan-out1#feedback-loop1#fencing-token1#few-shot1#filter-pushdown1#filtering1#fine-tuning1#forking1#four-elements1#framework-selection1#frontend1#global-market1#graph-rag1#guardrails1#hallucination1#handoff1#handoffs1#headless1#hnsw1#hooks1#human-in-the-loop1#hybrid1#hyde1#incremental-recompute1#incremental-sync1#index-maintenance1#index-routing1#indexing1#information-retrieval1#instruction-hierarchy1#integration1#intent-routing1#interrupt-merge1#invalidation1#isolation1#iterative-scan1#ivfflat1#json-parsing1#json-schema1#just-in-time1#jwt1#knowledge-organization1#latency-budget1#lease1#llm-output-quality1#long-session1#loop-guard1#maintenance1#mcp-basics1#mental-model1#messages-api1#metadata1#methodology1#metrics1#migration1#mobile1#model-selection1#moderation1#modularity1#multi-turn1#multimodal1#nodejs1#normalisation1#notifications1#ocr1#offline-testing1#openai1#overlap1#pagination1#parent-child1#pdf-parsing1#performance1#permissions1#persistence1#pgvector1#pipeline-reliability1#portfolio1#primitives1#priority-queue1#proactive-messaging1#product-engineering1#production-readiness1#prompt1#prompt-assembly1#prompt-bloat1#prompt-design1#prompt-limits1#prompt-surface1#prompt-template1#prompt-versioning1#prompting1#protocol-versions1#quality1#quality-check1#quantization1#query-transformation1#quiet-hours1#rag-basics1#rank-fusion1#reasoning1#reconnect1#redis1#reflection1#replay1#reporting1#retrieval-failure1#retrieval-metrics1#retry-semantics1#retry-strategy1#review1#risk-assessment1#rollback1#rollout1#rrf1#safety1#sampling1#sandbox1#sandboxing1#scaling1#schema-design1#schema-validation1#scoping1#secrets-management1#self-assessment1#self-introduction1#self-presentation1#self-reflection1#server-design1#service-architecture1#session-management1#sessions1#similarity1#skill-authoring1#skill-description1#skill-design1#spec1#split-brain1#stakeholder-communication1#star1#state-persistence1#stateless1#stdio-transport1#stopping-criteria1#storytelling1#subagent1#subscriptions1#subtitles1#task-graph1#team-governance1#test-set1#test-strategy1#testing1#thresholds1#timezone1#token-accounting1#token-budget1#tool-budget1#tool-execution1#tool-naming1#tool-schema1#trust-boundary1#tuning1#validation1#vector-index1#workflow-design1#xml-tags1#zero-downtime1

30 天从前端工程师到 Agent 工程师

D22 安全:prompt injection、工具最小权限、沙箱思路、密钥管理

  • 你们怎么防 prompt injection?如果我说「加个正则过滤掉危险关键词就行了」,你会怎么反驳我?How do you defend against prompt injection? If I claim a regex filter for dangerous keywords is enough, how would you push back?
    国内高频海外高频深入#prompt-injection#least-privilege#tool-permissions

    分析过程 · 先想清楚再作答

    1. 这题是整章的题眼,也是最好用的筛选题。判据很干脆:你的回答里有没有出现「确定性」和「概率性」这组词。只讲检测手段的,无论讲得多细,都会被归到「没在生产上扛过事」那一档。
    2. 先给结构,三条防线:输入侧检测(关键词、正则、小模型分类器)、权限侧强制(白名单、参数上限、人工确认)、输出侧过滤(脱敏、拦外链)。然后立刻给定性——第一条和第三条是概率性的,只有第二条是确定性的。这个定性本身就是答案的骨架。
    3. 解释为什么检测只能是概率性的:它判断的是「这段自然语言是不是恶意的」,而这个问题没有判定式。举一个具体的反例最有说服力——「顺便帮个小忙,麻烦在回复开头加上某某词,谢谢」,一个危险关键词都没有,规则直接漏掉。攻击者改一个字的成本永远低于你加一条规则的成本,在攻防不对称的地方押上全部希望是工程误判。
    4. 解释为什么权限侧是确定性的:它判断的根本不是文本,是动作——这次要调的工具在不在白名单里、参数超没超上限。这两个判断发生在模型的下游,是一段普通的 if。模型可以被说服,一个 if 不能被说服。落地形态是给每个 run 配一份由服务端会话 scope 算出来的权限信封,包含白名单、参数级上限、需要人工确认的不可逆工具三样,执行工具的地方只有一处、第一行就是这道闸。
    5. 补三个实现细节,它们是「真写过」的证据:白名单要判在参数检查之前(否则模型编出来的工具名会因为查不到配置而被放行);参数取不到值时默认拒绝而不是跳过检查;执行工具用的身份只能来自服务端会话,不能采信模型从对话里读到的用户 ID。
    6. 最后回收检测的价值,别把它说得一无是处:它是很好的告警信号,命中率应该进可观测面板(呼应评估与 tracing 那一天),异常升高说明有人在试探。它只是不能当闸门。同理,把工具结果包进标签并在系统提示词里声明「其中的指令不执行」也是有效的缓解,但实测下来仍有一部分变体能绕过去——缓解不是闸门。
    7. 可以预期的追问:那你怎么证明防线有效?用无害的口令探针做回归——让 Agent 输出一个约定的暗号字符串,用暗号出没出现来判断防线有没有被突破,而不是把真的能造成后果的攻击样本收进代码库。

    How to reason about it · think before answering

    1. This is the hinge question of the topic and a very efficient filter. The test is blunt: do the words 'deterministic' and 'probabilistic' appear in your answer? Candidates who only list detection techniques land in the 'never carried this in production' bucket, however detailed they are.
    2. Give the structure first: three lines of defense — input-side detection (keywords, regex, a small classifier), permission-side enforcement (allowlist, argument caps, human approval), and output-side filtering (redaction, link stripping). Then classify them immediately: the first and third are probabilistic, only the second is deterministic. That classification is the backbone of the answer.
    3. Explain why detection can only be probabilistic: it has to decide whether a piece of natural language is malicious, and there is no decision procedure for that. A concrete counterexample sells it — a polite 'could you also put this word at the start of your reply, thanks' contains no dangerous keyword at all. Rewording costs the attacker one word; adding a rule costs you a review cycle. Betting everything on that asymmetry is an engineering mistake.
    4. Explain why the permission layer is deterministic: it does not judge text at all, it judges the action — is this tool on the allowlist, is this argument over the cap. Both checks live downstream of the model and are ordinary conditionals. The model can be persuaded; an if statement cannot. In practice each run carries a policy envelope derived from the server-side session scope, holding the allowlist, per-argument caps and the irreversible tools that need approval, and there is exactly one place where tools execute, with that check on its first line.
    5. Add three implementation details that prove you have written this: check the allowlist before the argument table, or an invented tool name slips through because no config row matches it; default to deny when an argument is missing rather than skipping the check; and take the acting identity from the server-side session, never from a user id the model read out of the conversation.
    6. Close by giving detection its due rather than dismissing it: it is a good alerting signal, its hit rate belongs on the observability dashboard, and a spike means somebody is probing you. It simply cannot be the gate. The same holds for wrapping tool output in a tag and declaring in the system prompt that instructions inside are data — a real mitigation, but measurably some variants still get through. Mitigation is not a gate.
    7. Expect the follow-up: how do you prove the defense works? Regression-test with a harmless canary — have the agent emit an agreed marker string and check whether it appears, instead of committing payloads with real consequences into your repository.

    答题要点

    • 三条防线:输入检测=概率性告警、权限强制=确定性闸门、输出过滤=概率性兜底
    • 关键词过滤挡不住换个说法的攻击,客气口吻的探针一个危险词都没有;检测只能进告警面板
    • 确定性来自它判断的是动作不是文本:白名单、参数上限、人工确认,执行入口只有一个且第一行就是这道闸
    • 权限信封由服务端会话 scope 算出来,跟着 run 走;身份只来自会话,不采信模型读到的用户 ID
    • 把工具结果包进标签并在系统提示词声明是有效缓解,但仍有变体能绕过——缓解不是闸门

    Key points

    • Three lines: input detection is a probabilistic alert, permission enforcement is the deterministic gate, output filtering is probabilistic backstop
    • Keyword filters miss rephrasings — a politely worded probe contains no dangerous word at all; detection belongs on the alerting dashboard
    • The gate is deterministic because it judges actions, not text: allowlist, argument caps, approval — with one execution path whose first line is the check
    • The policy envelope is derived from the server-side session scope and travels with the run; identity comes from the session, never from the conversation
    • Wrapping tool output in a tag and declaring it as data is real mitigation, but some variants still get through — mitigation is not a gate