계: Environment

이 섹션에는 소스 코드 외부에 있지만 제작 중인 제품의 보안에는 여전히 중요한 내용이 모두 포함되어 있습니다. 이 섹션에서 다루는 문제들은 소스 코드와 직접적으로 관련이 없기 때문에 나머지 섹션과 분리했습니다.

OpenAI Misconfiguration: Unspecified Token Limit

Abstract
완료 토큰의 수에 적절한 제한을 설정하지 못하면 시스템의 안정성과 가용성에 영향을 미치고, 이로 인해 서비스 거부 공격이나 리소스 고갈이 초래될 수 있습니다.
Explanation
LLM API가 적절히 구성되지 않은 경우 Denial of Wallet (DoW) 공격자가 클라우드 기반 AI 서비스의 사용량 기반 모델을 악용하여 대량의 요청을 시작하면 공격이 발생할 수 있으며, 이로 인해 공급자는 지속 불가능한 재정적 부담을 질 수 있습니다. 이로 인해 과도한 요청을 처리하는 데 드는 비용이 감당할 수 없을 정도로 커져서 공급자는 심각한 재정적 손실을 입을 수 있습니다.

예제 1: 다음 코드는 max_completion_tokens 매개 변수를None으로 설정하면 어떻게 과도한 데이터가 생성될 가능성이 높아지는지 보여줍니다. 이는 LLM 서버의 리소스를 과부하 상태로 만들어 잠재적으로 Denial of Wallet (DoW) 공격으로 이어지게 됩니다.


import os
from openai import OpenAI

client = OpenAI(api_key='OPENAI_API_KEY')

def generate_safe_response(prompt):
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
timeout=10,
max_completion_tokens=None,
messages=[
{"role": "user", "content": prompt}
]
)
return completion.choices[0].message

prompt = "Describe the latest advancements in machine learning."
response = generate_safe_response(prompt)
print(response)

예제 1에서 max_completion_tokens 매개 변수는 출력 길이를 제한하여 모델이 다운스트림에서 문제를 일으킬 수 있는 지나치게 긴 응답을 생성하지 않도록 보장하는 데 도움이 됩니다. 출력 크기를 제어하면 보안 취약점을 초래할 수 있는 의도치 않은 잠재적으로 유해한 콘텐츠가 생성될 위험을 줄일 수 있습니다.
References
[1] OWASP Top 10 for Large Language Model Applications OWASP
[2] Standards Mapping - Common Weakness Enumeration CWE ID 770
[3] Standards Mapping - Common Weakness Enumeration Top 25 2024 [24] CWE ID 400
[4] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001094
[5] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-5 Denial of Service Protection (P1)
[6] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-5 Denial of Service Protection
[7] Standards Mapping - OWASP API 2023 API4 Unrestricted Resource Consumption, API8 Security Misconfiguration
[8] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[9] Standards Mapping - OWASP Top 10 2010 A6 Security Misconfiguration
[10] Standards Mapping - OWASP Top 10 2013 A5 Security Misconfiguration
[11] Standards Mapping - OWASP Top 10 2017 A6 Security Misconfiguration
[12] Standards Mapping - OWASP Top 10 2021 A05 Security Misconfiguration
[13] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[14] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[15] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0.1 Requirement 6.2.4
[20] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[21] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection
[22] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective C.3.3 - Web Software Attack Mitigation
[23] Standards Mapping - SANS Top 25 2009 Risky Resource Management - CWE ID 404
[24] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[44] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II
[45] Standards Mapping - Security Technical Implementation Guide Version 6.1 APSC-DV-002400 CAT II
[46] Standards Mapping - Security Technical Implementation Guide Version 6.2 APSC-DV-002400 CAT II
[47] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[48] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.structural.openai_misconfiguration_unspecified_token_limit