Secure Coding Guide | 하드 코드된 비밀번호

정의

소스 코드내에 비밀번호가 하드코딩되어 있어 소스코드 유출시 노출될 우려가 있거나 주기적 변경 등과 같은 수정(관리자 변경 등)이 용이하지 않는 보안약점이다.

영향

패스워드 노출된다.

발생 및 조치 방법

프로그램 코드 내부에 하드 코드된 패스워드가 포함된 경우 발생한다.

안전하지 않은 Java 코드의 예

public Connection DBConnect(String url, String id) { try { String url = props.getProperty("url"); String id = props.getProperty("id"); conn = DriverManager.getConnection(url, id, "tiger"); } catch (SQLException e) { System.err.println("..."); } return conn; }

안전한 Java 코드의 예

public Connection DBConnect(String url, String id) { try { String url = props.getProperty("url"); String id = props.getProperty("id"); String pwd = props.getProperty("passwd"); ... byte[] decrypted_pwd = cipher.doFinal(pwd.getBytes()); pwd = new String(decrypted_pwd); conn = DriverManager.getConnection(url, id, pwd); } catch (SQLException e) { System.err.println("..."); } return conn; }



최종 수정 : 2018-05-27