Shellshock (CVE‑2014‑6271 · 7169)

CVSS: 10.0 (Critical)


🧠 주요 개념 정리

🔹 환경 변수 (Environment Variable)

🔹 CGI (Common Gateway Interface)


🧨 취약점 발생 구조

export x='() { :; }; echo VULNERABLE'
bash -c 'echo Safe'

🔍 Bash 내부 소스 분석

if (privmode == 0 && read_but_dont_execute == 0 &&
    STREQN("() {", string, 4)) {
    temp_string = malloc(...);
    strcpy(temp_string, name);
    strcat(temp_string, " ");
    strcat(temp_string, string);
    parse_and_execute(temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
}

🛠️ 패치 전/후 동작 비교

취약:

export x='() { :; }; echo VULNERABLE'
bash -c 'echo Safe'

# --- 실행 시 출력 내용 ---
# exploited
# safe

패치 이후:

export x='() { :; }; echo VULNERABLE'
bash -c 'echo Safe'

# --- 실행 시 출력 내용 ---
# bash: warning x: ignoring function definition attempt
# bash: error importing function definition for 'x'

🔐 대응 및 패치


🔗 참고 문헌

← 목록으로