0Pricing
MCP Academy · 강의

모든 항목 검증 및 정제하기

모델이 제공한 입력을 신뢰할 수 없는 데이터로 취급합니다.

모든 항목 검증 및 정제하기은(는) CoddyKit의 무료 MCP Academy 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 MCP Academy 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. MCP Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Inputs Are Untrusted

Every argument the model passes to a tool is untrusted input. The model may be honest, but its arguments can be shaped by injected text, so verify them. 🔎

Validate Before You Act

Check shape, type, and range before a tool does anything real. Validation at the door turns a vague bad call into a clear, safe rejection.

Let Pydantic Help

Type hints and Pydantic models reject malformed arguments before your code runs. This input must be a positive int, so a string or a negative value is refused early.

from pydantic import Field

@mcp.tool()
def get_page(n: int = Field(gt=0, le=100)) -> str:
    return load(n)

Bound the Values

Cap sizes, lengths, and counts. A limit field on a query keeps the model from asking for a million rows and turning one call into a denial of service.

Sanitize for the Destination

Sanitizing means making input safe for where it lands. A value safe in a log can be dangerous in a shell, a SQL string, or a file path.

Never Build SQL by Hand

String-concatenated SQL invites injection. Use parameterized queries so the database treats model input strictly as a value, never as executable code.

cur.execute(
    "SELECT * FROM orders WHERE id = ?",
    (order_id,),
)

Guard the Shell

If a tool runs a command, never paste arguments into a shell string. Pass an argument list and avoid shell parsing so input cannot smuggle in extra commands.

Resolve and Confine Paths

For file tools, resolve the path to its canonical form and confirm it stays inside your allowed root. Reject anything with a path traversal like dot-dot.

p = (ROOT / name).resolve()
if not p.is_relative_to(ROOT):
    raise ValueError("path escapes root")

Fail Closed

When input does not pass a check, stop and return a clear error. Failing closed beats guessing, because a wrong guess can be exactly what an attacker wants.

Do Not Trust Tool Output Either

Data your tool returns can carry injected instructions onward. Where it matters, label or escape fetched content so the model treats it as data, not orders.

Validate at Every Boundary

Check input as it enters your tool and again before it hits a database, file, or API. Each boundary is a fresh chance to catch something unsafe.

Quick Check

Which choice best protects a SQL query from injection?

Recap

Treat all tool inputs as untrusted: validate types and ranges, sanitize for the destination, confine paths, and fail closed. Distrust the input. ✅

자주 묻는 질문

“모든 항목 검증 및 정제하기” 강의는 무료인가요?

네 — “모든 항목 검증 및 정제하기” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 MCP Academy 강의 전체를 잠금 해제할 수 있습니다. MCP Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

“모든 항목 검증 및 정제하기”에서 뭘 배우나요?

모델이 제공한 입력을 신뢰할 수 없는 데이터로 취급합니다. 브라우저에서 직접 실행하는 실습 코드로 MCP Academy을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

MCP Academy을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 MCP Academy은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.

“모든 항목 검증 및 정제하기” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 MCP Academy 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 MCP Academy 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. MCP 고유의 위협
  2. 최소 권한의 도구 접근
  3. 모든 항목 검증 및 정제하기
  4. 파괴적 작업 보호하기
← MCP Academy(으)로 돌아가기