# 다운스트림 컴포넌트가 사용하는 출력의 특수 요소에 대한 부적절한 무효화('인젝션') (CWE-74) 제품이 업스트림 컴포넌트로부터 외부 영향을 받은 입력을 사용해 명령, 데이터 구조 또는 레코드의 전부 또는 일부를 구성하지만, 다운스트림 컴포넌트로 전송될 때 어떻게 파싱되거나 해석되는지를 변경할 수 있는 특수 요소를 무효화하지 않거나 잘못 무효화합니다. **Stack:** Go - Prevalence: 높음 자주 악용됨 - Impact: 높음 3개의 높은 심각도 규칙 - Prevention: 문서화됨 3개의 수정 예시 **OWASP:** Injection (A03:2021-Injection) - #3 ## Description Software has certain assumptions about what constitutes data and control. Injection problems occur when these assumptions are violated. Attackers exploit this by inserting special characters or instructions that modify the intended interpretation. ## Prevention 1개의 Shoulder 탐지 규칙을 기반으로 한 Injection 예방 전략. ### Go Use structured prompts with clear system/user boundaries and sanitize user input ## Warning Signs - [HIGH] User input flows to ... without sanitization - [HIGH] user input flowing to LLM prompts without sanitization ## Consequences - 승인되지 않은 코드 실행 - 애플리케이션 데이터 읽기 - 애플리케이션 데이터 수정 - 보호 메커니즘 우회 ## Mitigations - 코드와 데이터를 분리하는 파라미터화된 인터페이스를 사용하세요 - 다운스트림 컴포넌트에서 사용하기 전에 모든 입력을 검증하고 인코딩하세요 - 가능한 경우 입력 검증에 허용 목록을 사용하세요 ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Go (1 rules) - **AI Prompt Injection** [HIGH]: Detects user input flowing to LLM prompts without sanitization. - Remediation: Sanitize user input and use structured prompts with clear system/user boundaries. ```go sanitized := sanitize(userInput) messages := []openai.ChatCompletionMessage{ {Role: "system", Content: systemPrompt}, {Role: "user", Content: sanitized}, } ``` Learn more: https://shoulder.dev/learn/go/cwe-74/prompt-injection