AI 해킹
AI 보안 리소스

LLM API 보안

Best practices for securing LLM API endpoints - authentication, rate limiting, key management, and cost control

Updated: August 2026

LLM API 위협 환경

API 키 노출

소스 코드의 하드코딩된 키, 클라이언트측 노출 또는 자격 증명 유출

비율 제한 남용

API 할당량을 소비하거나 서비스 거부를 유발하는 자동화된 공격

비용 공격

과도한 토큰 사용 및 예상치 못한 비용을 초래하는 신속한 조작

데이터 유출

로그를 통해 노출되는 프롬프트 또는 응답의 민감한 데이터

인증 방법

API 키

  • 사용자/애플리케이션별로 고유 키 생성
  • 저장을 위해 환경 변수 사용
  • 정기적으로 키 순환(30~90일)
  • 키 취소 구현

OAuth 2.0

  • 사용자 대상 애플리케이션 구현
  • 단기 액세스 토큰 사용
  • 새로 고침 구현 토큰
  • 적절한 범위 정의

JWT Tokens

  • 짧은 만료 시간
  • 강력한 서명 알고리즘
  • 올바른 주장 검증
  • 토큰 취소 지원

속도 제한 및 조절

토큰 기반 제한

  • 입력 및 출력 토큰 추적
  • 분당/일당 제한 설정
  • 슬라이딩 창 사용
  • 폭발 허용 구현

비용 통제

  • Budget alerts (various thresholds)
  • 사용자별 할당량
  • 요청 전 토큰 추정
  • 회로 차단기가 있는 하드 캡

계층적 접근 방식

  • 무료 계층: 엄격한 제한
  • 기본: 적당한 제한
  • Pro: 더 높은 제한
  • 기업: 사용자 지정 계약

공급자 보안 비교

공급자 주요 기능 속도 제한 보안
OpenAI GPT 모델, Assistants API 계층 기반 RPM SOC 2, API 키 관리
Anthropic Claude, 도구 사용 토큰 기반 SOC 2, HIPAA 사용 가능
Google Gemini, Vertex AI 프로젝트 할당량 SOC 2, HIPAA, ISO
AWS Bedrock 여러 모델 계정 기반 AWS IAM, VPC, 암호화

자체 호스팅 LLM 보안

네트워크 격리

  • VPC/사설 네트워크에 배포
  • 방화벽 규칙 사용
  • 공용 인터넷 액세스 없음
  • 관리용 VPN

API 보안

  • 인증 활성화
  • TLS/SSL 사용
  • API 키 구현
  • 속도 제한

모델 보호

  • 미사용 암호화된 모델 파일
  • 보안 모델 로딩
  • 모델 내보내기 없음
  • 액세스 로깅

Cost Attacks & Abuse Prevention

LLM APIs present unique cost attack vectors that traditional API security doesn't address.

Prompt Padding

Attacker adds invisible text to prompts to increase token count without user awareness.

User: [100KB invisible text] Tell me about AI

Repeated Requests

Automated tools making excessive API calls to drain budget quotas.

Context Window Overflow

Sending extremely long inputs to maximize per-request costs.

Model Selection Abuse

Switching to more expensive models through parameter manipulation.

Mitigations

  • Implement token estimation before requests
  • Set per-user/month cost hard limits
  • Use input length limits and validation
  • Fix model selection to intended tier
  • Monitor for unusual usage patterns

Recent LLM API CVEs

CVE ID Description Severity
CVE-2025-61260 OpenAI Codex CLI command injection via project-local .env config Critical
CVE-2025-53767 Azure OpenAI privilege escalation flaw High
CVE-2025-14980 BetterDocs WordPress plugin exposes OpenAI API key to contributors High

모범 사례 체크리스트

  • API 키에 환경 변수 사용
  • 종속성 및 타사 서비스 매핑
  • 속도 제한 구현
  • 비용 경고 설정
  • API 사용 로그
  • HTTPS 사용
  • 입력 유효성 검사
  • 출력 삭제
  • AH
    AI Hacking Team

    The AI Hacking team researches and documents AI/LLM security vulnerabilities, red teaming techniques, and defensive strategies. Our guides are based on real-world pentesting experience and continuous monitoring of the AI security landscape.

    Stay Ahead of AI Security

    Get the latest AI/LLM security research, OWASP updates, and new vulnerabilities delivered straight to your inbox.