☕ Java 코드 에디터
취약한 코드
// [취약] 보안에 부적합한 API: 예측가능 Random, 문자열 exec(셸 인젝션)
Random rnd = new Random();
String token = Long.toHexString(rnd.nextLong());
Runtime.getRuntime().exec("sh -c 'backup " + name + "'");
💡 수정 가이드 (KISA 기준)
1. 안전한 API
SecureRandom + ProcessBuilder.
SecureRandom rnd = new SecureRandom();
String token = Long.toHexString(rnd.nextLong());
new ProcessBuilder("backup", name).start(); // 인자 분리(셸 미경유)
📊 분석 결과 및 설명
🎯 목표
보안에 부적합한 오래된/위험한 API를 안전한 대체 API로 교체합니다.
⚠️ 현재 취약점
Dangerous API Use
예측가능 난수/문자열 exec로 토큰 예측·명령 주입이 가능합니다.