소프트웨어 보안은 보안 소프트웨어가 아닙니다. 여기서는 인증, 액세스 제어, 기밀성, 암호화, 권한 관리 등의 항목에 대해 설명합니다.
12345
로 설정합니다.
...
kind: KubeletConfiguration
...
readOnlyPort: 12345
...
default
서비스 계정이 할당됩니다. 각 서비스 계정에 대해 API 액세스 토큰이 자동으로 생성되어 탑재된 디렉터리에서 사용할 수 있습니다. 공격자는 손상된 Container의 액세스 토큰을 사용하여 충분히 보호되지 않고 보안에 민감한 서비스 API에 액세스할 수 있습니다.automountServiceAccountToken
이 정의되지 않았거나 default 서비스 계정에 automountServiceAccountToken: true
설정이 포함되어 있기 때문에 Pod의 default 서비스 계정에 대한 API 자격 증명 자동 탑재가 비활성화되지 않습니다.automountServiceAccountToken
이 정의되지 않았거나 true
로 설정되어 있으면 Pod의 default
서비스 계정에 대한 API 자격 증명이 자동 탑재됩니다.예제 2: 이 예제에서처럼
apiVersion: v1
kind: ServiceAccount
metadata:
name: default
namespace: demo-namespace
automountServiceAccountToken: true
...
default
서비스 계정에 automountServiceAccountToken: true
설정이 있기 때문에 Pod에 대해 API 자격 증명이 자동 탑재됩니다.
apiVersion: v1
kind: Pod
...
spec:
automountServiceAccountToken: true
...
--use-service-account-credentials=true
플래그가 포함되어 있지 않기 때문에 서비스 계정 자격 증명이 컨트롤러 간에 공유됩니다. 이 플래그는 컨트롤러 관리자가 별도의 서비스 계정을 사용하여 각 컨트롤러를 시작하도록 지시합니다. RBAC(Role-Based Access Control)와 함께 사용하면 각 컨트롤러가 해당 작업을 수행하는 데 필요한 최소 권한으로 실행됩니다.--use-service-account-credentials
플래그 없이 Kubernetes 컨트롤러 관리자를 시작합니다.
apiVersion: v1
kind: Pod
...
spec:
containers:
- command:
- /usr/local/bin/kube-controller-manager
image: k8s.gcr.io/kube-controller-manager:v1.9.7
...
--token-auth-file
플래그를 사용하여 정적 토큰으로 요청을 인증하는 Kubernetes API 서버를 시작합니다.
...
spec:
containers:
- command:
- kube-apiserver
...
- --token-auth-file=<filename>
...
chroot()
와 같은 작업을 수행하는 데 필요한 높은 수준의 권한은 작업을 수행한 직후 삭제해야 합니다.chroot()
등의 권한 있는 함수를 호출하려면 먼저 root
권한을 획득해야 합니다. 권한 있는 작업이 완료되자 마자 프로그램은 root
권한을 삭제하고 호출한 사용자의 권한 수준으로 돌아가야 합니다.chroot()
를 호출하여 응용 프로그램을 APP_HOME
아래 파일 시스템의 부분 집합으로 제한합니다. 그런 다음 코드는 사용자가 지정한 파일을 열고 파일의 내용을 처리합니다.
...
chroot(APP_HOME);
chdir("/");
FILE* data = fopen(argv[1], "r+");
...
setuid()
를 호출하지 않으면 응용 프로그램이 계속 불필요한 root
권한으로 동작하게 됩니다. 악의적인 연산이 수퍼유저 권한으로 수행되기 때문에 공격자가 응용 프로그램에 대한 익스플로이트에 성공하면 권한 상승 공격이 일어날 수 있습니다. 응용 프로그램이 root
사용자가 아닌 권한 수준으로 떨어지면 피해 가능성이 대폭 줄어듭니다.clone()
메서드에서 동일한 검사를 수행해야 합니다.clone()
메서드가 호출될 때 복제될 클래스에 대한 구성자는 호출되지 않습니다. 따라서, SecurityManager 또는 AccessController 검사가 cloneable 클래스의 구성자에 존재하는 경우, 동일한 검사가 클래스의 clone 메서드에도 존재해야 합니다. 그렇지 않으면, 클래스가 복제될 때 보안 검사가 무시됩니다.clone()
메서드가 아니라 구성자의 SecurityManager
검사가 포함되어 있습니다.
public class BadSecurityCheck implements Cloneable {
private int id;
public BadSecurityCheck() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new BadPermission("BadSecurityCheck"));
}
id = 1;
}
public Object clone() throws CloneNotSupportedException {
BadSecurityCheck bsm = (BadSecurityCheck)super.clone();
return null;
}
}
SecurityManager
검사를 수행하는 serializable 클래스는 readObject()
및 readObjectNoData
메서드에서 동일한 검사를 수행해야 합니다.readObject()
메서드가 호출될 때 역직렬화될 클래스에 대한 구성자는 호출되지 않습니다. 따라서, SecurityManager
검사가 serializable 클래스의 구성자에 존재하는 경우, 동일한 SecurityManager
검사가 readObject()
및 readObjectNoData()
메서드에도 존재해야 합니다. 그렇지 않으면, 클래스가 역직렬화될 때 보안 검사가 무시됩니다.readObject()
및 readObjectNoData()
메서드가 아니라 구성자의 SecurityManager
검사가 포함됩니다.
public class BadSecurityCheck implements Serializable {
private int id;
public BadSecurityCheck() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new BadPermission("BadSecurityCheck"));
}
id = 1;
}
public void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
in.defaultReadObject();
}
public void readObjectNoData(ObjectInputStream in) throws ClassNotFoundException, IOException {
in.defaultReadObject();
}
}
...
var fs:FileStream = new FileStream();
fs.open(new File("config.properties"), FileMode.READ);
var password:String = fs.readMultiByte(fs.bytesAvailable, File.systemCharset);
URLRequestDefaults.setLoginCredentialsForHost(hostname, usr, password);
...
password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
string password = regKey.GetValue(passKey).ToString());
NetworkCredential netCred =
new NetworkCredential(username,password,domain);
...
password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
RegQueryValueEx(hkey,TEXT(.SQLPWD.),NULL,
NULL,(LPBYTE)password, &size);
rc = SQLConnect(*hdbc, server, SQL_NTS, uid,
SQL_NTS, password, SQL_NTS);
...
password
값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 접근 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
01 RECORD.
05 UID PIC X(10).
05 PASSWORD PIC X(10).
...
EXEC CICS
READ
FILE('CFG')
INTO(RECORD)
RIDFLD(ACCTNO)
...
END-EXEC.
EXEC SQL
CONNECT :UID
IDENTIFIED BY :PASSWORD
AT :MYCONN
USING :MYSERVER
END-EXEC.
...
CFG
에 대한 액세스 권한이 있는 사용자면 누구나 암호의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
<cfquery name = "GetCredentials" dataSource = "master">
SELECT Username, Password
FROM Credentials
WHERE DataSource="users"
</cfquery>
...
<cfquery name = "GetSSNs" dataSource = "users"
username = "#Username#" password = "#Password#">
SELECT SSN
FROM Users
</cfquery>
...
master
테이블에 대한 액세스 권한이 있는 사용자면 누구나 Username
및 Password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
file, _ := os.Open("config.json")
decoder := json.NewDecoder(file)
decoder.Decode(&values)
request.SetBasicAuth(values.Username, values.Password)
...
values.Password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 접근 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
Properties prop = new Properties();
prop.load(new FileInputStream("config.properties"));
String password = prop.getProperty("password");
DriverManager.getConnection(url, usr, password);
...
password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
String username = credentials[0];
String password = credentials[1];
handler.proceed(username, password);
}
});
...
...
obj = new XMLHttpRequest();
obj.open('GET','/fetchusers.jsp?id='+form.id.value,'true','scott','tiger');
...
plist
파일에서 암호를 읽고, 암호로 보호되는 파일의 압축을 풀 때 이 암호를 사용합니다.
...
NSDictionary *dict= [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Config" ofType:@"plist"]];
NSString *password = [dict valueForKey:@"password"];
[SSZipArchive unzipFileAtPath:zipPath toDestination:destPath overwrite:TRUE password:password error:&error];
...
...
$props = file('config.properties', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$password = $props[0];
$link = mysql_connect($url, $usr, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
...
password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
ip_address := OWA_SEC.get_client_ip;
IF ((OWA_SEC.get_user_id = 'scott') AND
(OWA_SEC.get_password = 'tiger') AND
(ip_address(1) = 144) and (ip_address(2) = 25)) THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
...
...
props = os.open('config.properties')
password = props[0]
link = MySQLdb.connect (host = "localhost",
user = "testuser",
passwd = password,
db = "test")
...
password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
require 'pg'
...
passwd = ENV['PASSWD']
...
conn = PG::Connection.new(:dbname => "myApp_production", :user => username, :password => passwd, :sslmode => 'require')
PASSWD
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
val prop = new Properties()
prop.load(new FileInputStream("config.properties"))
val password = prop.getProperty("password")
DriverManager.getConnection(url, usr, password)
...
config.properties
에 대한 접근 권한이 있는 사용자라면 누구나 password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 접근 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.plist
파일에서 암호를 읽고, 암호로 보호되는 파일의 압축을 풀 때 이 암호를 사용합니다.
...
var myDict: NSDictionary?
if let path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist") {
myDict = NSDictionary(contentsOfFile: path)
}
if let dict = myDict {
zipArchive.unzipOpenFile(zipPath, password:dict["password"])
}
...
...
Private Declare Function GetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long
...
Dim password As String
...
password = GetPrivateProfileString("MyApp", "Password", _
"", value, Len(value), _
App.Path & "\" & "Config.ini")
...
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=" & password &";"
...
password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
password = ''.
...
...
URLRequestDefaults.setLoginCredentialsForHost(hostname, "scott", "");
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
var storedPassword:String = "";
var temp:String;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(storedPassword.equals(userPassword))
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 빈 문자열을 입력하여 암호 확인을 무시할 수 있습니다.
...
HttpRequest req = new HttpRequest();
req.setClientCertificate('mycert', '');
...
...
NetworkCredential netCred = new NetworkCredential("scott", "", domain);
...
Example 1
의 코드가 성공하면 네트워크 자격 증명 로그인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
string storedPassword = "";
string temp;
if ((temp = ReadPassword(storedPassword)) != null) {
storedPassword = temp;
}
if(storedPassword.Equals(userPassword))
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 빈 문자열을 입력하여 암호 확인을 무시할 수 있습니다.
...
rc = SQLConnect(*hdbc, server, SQL_NTS, "scott", SQL_NTS, "", SQL_NTS);
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
char *stored_password = "";
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password))
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 user_password
에 대해 빈 문자열을 입력하여 암호 확인을 무시할 수 있습니다.
...
<cfquery name = "GetSSNs" dataSource = "users"
username = "scott" password = "">
SELECT SSN
FROM Users
</cfquery>
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
var password = "";
var temp;
if ((temp = readPassword()) != null) {
password = temp;
}
if(password == userPassword()) {
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 빈 문자열을 입력하여 암호 확인을 무시할 수 있습니다.
...
response.SetBasicAuth(usrName, "")
...
...
DriverManager.getConnection(url, "scott", "");
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
String storedPassword = "";
String temp;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(storedPassword.equals(userPassword))
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 빈 문자열을 입력하여 암호 확인을 무시할 수 있습니다.
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
String username = "";
String password = "";
if (handler.useHttpAuthUsernamePassword()) {
String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
username = credentials[0];
password = credentials[1];
}
handler.proceed(username, password);
}
});
...
Example 2
와 마찬가지로 useHttpAuthUsernamePassword()
에서 false
를 반환하면 공격자가 빈 암호를 입력하여 보호된 페이지를 볼 수 있습니다.
...
obj = new XMLHttpRequest();
obj.open('GET','/fetchusers.jsp?id='+form.id.value,'true','scott','');
...
{
...
"password" : ""
...
}
...
rc = SQLConnect(*hdbc, server, SQL_NTS, "scott", SQL_NTS, "", SQL_NTS);
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
NSString *stored_password = "";
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password)) {
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 user_password
에 대해 빈 문자열을 입력하여 암호 확인을 무시할 수 있습니다.
<?php
...
$connection = mysql_connect($host, 'scott', '');
...
?>
DECLARE
password VARCHAR(20);
BEGIN
password := "";
END;
...
db = mysql.connect("localhost","scott","","mydb")
...
...
conn = Mysql.new(database_host, "scott", "", databasename);
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.""
로 설정될 수 있습니다. 이 경우에는 암호가 함수에 전달되도록 인수의 개수를 올바르게 지정해야 합니다.
...
ws.url(url).withAuth("john", "", WSAuthScheme.BASIC)
...
...
let password = ""
let username = "scott"
let con = DBConnect(username, password)
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
var stored_password = ""
readPassword(stored_password)
if(stored_password == user_password) {
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 user_password
에 대해 빈 문자열을 입력하여 암호 확인을 무시할 수 있습니다.
...
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=;"
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
password = 'tiger'.
...
...
URLRequestDefaults.setLoginCredentialsForHost(hostname, "scott", "tiger");
...
...
HttpRequest req = new HttpRequest();
req.setClientCertificate('mycert', 'tiger');
...
...
NetworkCredential netCred =
new NetworkCredential("scott", "tiger", domain);
...
...
rc = SQLConnect(*hdbc, server, SQL_NTS, "scott",
SQL_NTS, "tiger", SQL_NTS);
...
...
MOVE "scott" TO UID.
MOVE "tiger" TO PASSWORD.
EXEC SQL
CONNECT :UID
IDENTIFIED BY :PASSWORD
AT :MYCONN
USING :MYSERVER
END-EXEC.
...
...
<cfquery name = "GetSSNs" dataSource = "users"
username = "scott" password = "tiger">
SELECT SSN
FROM Users
</cfquery>
...
...
var password = "foobarbaz";
...
javap -c
명령을 사용하여 암호 값이 들어갈 디스어셈블된 코드에 액세스할 수 있다는 것입니다. Example 1
의 예제를 실행한 결과는 다음과 비슷합니다.
javap -c ConnMngr.class
22: ldc #36; //String jdbc:mysql://ixne.com/rxsql
24: ldc #38; //String scott
26: ldc #17; //String tiger
password := "letmein"
...
response.SetBasicAuth(usrName, password)
...
DriverManager.getConnection(url, "scott", "tiger");
...
javap -c
명령을 사용하여 암호 값이 들어갈 디스어셈블된 코드에 액세스할 수 있다는 것입니다. Example 1
의 예제를 실행한 결과는 다음과 비슷합니다.
javap -c ConnMngr.class
22: ldc #36; //String jdbc:mysql://ixne.com/rxsql
24: ldc #38; //String scott
26: ldc #17; //String tiger
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
handler.proceed("guest", "allow");
}
});
...
Example 1
과 마찬가지로 이 코드는 정상 실행되지만 코드에 접근할 수 있는 사용자는 암호에도 접근할 수 있습니다.
...
obj = new XMLHttpRequest();
obj.open('GET','/fetchusers.jsp?id='+form.id.value,'true','scott','tiger');
...
...
{
"username":"scott"
"password":"tiger"
}
...
...
DriverManager.getConnection(url, "scott", "tiger")
...
javap -c
명령을 사용하여 암호 값이 들어갈 디스어셈블된 코드에 액세스할 수 있다는 것입니다. Example 1
의 예제를 실행한 결과는 다음과 비슷합니다.
javap -c ConnMngr.class
22: ldc #36; //String jdbc:mysql://ixne.com/rxsql
24: ldc #38; //String scott
26: ldc #17; //String tiger
...
webview.webViewClient = object : WebViewClient() {
override fun onReceivedHttpAuthRequest( view: WebView,
handler: HttpAuthHandler, host: String, realm: String
) {
handler.proceed("guest", "allow")
}
}
...
Example 1
과 마찬가지로 이 코드는 정상 실행되지만 코드에 접근할 수 있는 사용자는 암호에도 접근할 수 있습니다.
...
rc = SQLConnect(*hdbc, server, SQL_NTS, "scott",
SQL_NTS, "tiger", SQL_NTS);
...
...
$link = mysql_connect($url, 'scott', 'tiger');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
...
DECLARE
password VARCHAR(20);
BEGIN
password := "tiger";
END;
password = "tiger"
...
response.writeln("Password:" + password)
...
Mysql.new(URI(hostname, 'scott', 'tiger', databasename)
...
...
ws.url(url).withAuth("john", "secret", WSAuthScheme.BASIC)
...
javap -c
명령을 사용하여 암호 값이 들어갈 디스어셈블된 코드에 액세스할 수 있다는 것입니다. Example 1
의 예제를 실행한 결과는 다음과 비슷합니다.
javap -c MyController.class
24: ldc #38; //String john
26: ldc #17; //String secret
...
let password = "secret"
let username = "scott"
let con = DBConnect(username, password)
...
예제 2: 다음 ODBC 연결 문자열은 하드코드된 비밀번호를 사용합니다.
...
https://user:secretpassword@example.com
...
...
server=Server;database=Database;UID=UserName;PWD=Password;Encrypt=yes;
...
...
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=tiger;"
...
...
credential_settings:
username: scott
password: tiger
...
<form method="get">
Name of new user: <input type="text" name="username">
Password for new user: <input type="password" name="user_passwd">
<input type="submit" name="action" value="Create User">
</form>
method
속성의 기본값이 GET
이므로 속성을 생략하면 동일한 결과가 나옵니다.
...
<param name="foo" class="org.jasypt.util.password.BasicPasswordEncoder">
...
</param>
...
import hashlib
def register(request):
password = request.GET['password']
username = request.GET['username']
hash = hashlib.md5(get_random_salt() + ":" + password).hexdigest()
store(username, hash)
...
require 'openssl'
def register(request)
password = request.params['password']
username = request.params['username']
salt = get_random_salt
hash = OpenSSL::Digest.digest("MD5", salt + ":" + password)
store(username, hash)
end
...
Null
암호는 보안을 침해할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
var storedPassword:String = null;
var temp:String;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(Utils.verifyPassword(userPassword, storedPassword))
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
string storedPassword = null;
string temp;
if ((temp = ReadPassword(storedPassword)) != null) {
storedPassword = temp;
}
if (Utils.VerifyPassword(storedPassword, userPassword)) {
// Access protected resources
...
}
...
ReadPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 비밀번호를 검색하지 못하면 공격자가 userPassword
에 대해 null
값을 입력하여 비밀번호 확인을 무시할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
string storedPassword = null;
string temp;
if ((temp = ReadPassword(storedPassword)) != null) {
storedPassword = temp;
}
if(Utils.VerifyPassword(storedPassword, userPassword))
// Access protected resources
...
}
...
ReadPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
char *stored_password = NULL;
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password))
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 user_password
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
을 지정하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
String storedPassword = null;
String temp;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(Utils.verifyPassword(userPassword, storedPassword))
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.null
로 초기화하고, 서버가 현재 요청을 이전에 거부하지 않은 경우 Android WebView 저장소에서 자격 증명을 읽은 후 보호된 페이지를 보기 위한 인증을 설정하는 데 사용합니다.
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
String username = null;
String password = null;
if (handler.useHttpAuthUsernamePassword()) {
String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
username = credentials[0];
password = credentials[1];
}
handler.proceed(username, password);
}
});
...
Example 1
과 마찬가지로 useHttpAuthUsernamePassword()
에서 false
를 반환하면 공격자가 null
암호를 입력하여 보호된 페이지를 볼 수 있습니다.null
암호를 사용하는 것은 좋은 방법이 아닙니다.null
로 설정합니다.
...
var password=null;
...
{
password=getPassword(user_data);
...
}
...
if(password==null){
// Assumption that the get didn't work
...
}
...
null
을 할당하지 마십시오.null
암호를 초기화합니다.
{
...
"password" : null
...
}
null
암호를 사용합니다. Null
암호는 보안을 침해할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
NSString *stored_password = NULL;
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password)) {
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 user_password
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
<?php
...
$storedPassword = NULL;
if (($temp = getPassword()) != NULL) {
$storedPassword = $temp;
}
if(strcmp($storedPassword,$userPassword) == 0) {
// Access protected resources
...
}
...
?>
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화합니다.
DECLARE
password VARCHAR(20);
BEGIN
password := null;
END;
null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
storedPassword = NULL;
temp = getPassword()
if (temp is not None) {
storedPassword = temp;
}
if(storedPassword == userPassword) {
// Access protected resources
...
}
...
getPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 userPassword
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.nil
을 할당하는 것은 잘못된 방법입니다.nil
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
@storedPassword = nil
temp = readPassword()
storedPassword = temp unless temp.nil?
unless Utils.passwordVerified?(@userPassword, @storedPassword)
...
end
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 @userPassword
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.nil
로 설정될 수 있습니다. 이 경우에는 암호가 함수에 전달되도록 인수의 개수를 올바르게 지정해야 합니다.null
을 지정하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
ws.url(url).withAuth("john", null, WSAuthScheme.BASIC)
...
null
암호를 사용합니다. Null
암호는 보안을 침해할 수 있습니다.nil
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 저장된 암호 값을 읽으려고 함으로써 사용자가 제공하는 값과 비교합니다.
...
var stored_password = nil
readPassword(stored_password)
if(stored_password == user_password) {
// Access protected resources
...
}
...
readPassword()
가 데이터베이스 오류 또는 다른 문제로 인해 저장된 암호를 검색하지 못하면 공격자가 user_password
에 대해 null
값을 입력하여 암호 확인을 무시할 수 있습니다.null
을 할당하는 것은 잘못된 방법입니다.null
로 초기화하고 이를 사용하여 데이터베이스에 연결합니다.
...
Dim storedPassword As String
Set storedPassword = vbNullString
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=" & storedPassword &";"
...
Example 1
의 코드가 성공하면 데이터베이스 사용자 계정인 “scott”이 공격자가 쉽게 추측할 수 있는 빈 암호로 구성되어 있음을 나타냅니다. 프로그램을 공개한 후에는 비어 있지 않은 암호를 사용하기 위한 계정 업데이트를 위해 코드 변경이 필요합니다.
...
* Default username for FTP connection is "scott"
* Default password for FTP connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
* Default username for database connection is "scott"
* Default password for database connection is "tiger"
...
...
<!-- Default username for database connection is "scott" -->
<!-- Default password for database connection is "tiger" -->
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
-- Default username for database connection is "scott"
-- Default password for database connection is "tiger"
...
...
# Default username for database connection is "scott"
# Default password for database connection is "tiger"
...
...
#Default username for database connection is "scott"
#Default password for database connection is "tiger"
...
...
// Default username for database connection is "scott"
// Default password for database connection is "tiger"
...
...
'Default username for database connection is "scott"
'Default password for database connection is "tiger"
...
response.sendRedirect("j_security_check?j_username="+usr+"&j_password="+pass);
...
var fs:FileStream = new FileStream();
fs.open(new File("config.properties"), FileMode.READ);
var decoder:Base64Decoder = new Base64Decoder();
decoder.decode(fs.readMultiByte(fs.bytesAvailable, File.systemCharset));
var password:String = decoder.toByteArray().toString();
URLRequestDefaults.setLoginCredentialsForHost(hostname, usr, password);
...
config.properties
에 액세스할 수 있는 모든 사용자는 password
값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
string value = regKey.GetValue(passKey).ToString());
byte[] decVal = Convert.FromBase64String(value);
NetworkCredential netCred =
new NetworkCredential(username,decVal.toString(),domain);
...
password
의 값을 읽을 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
RegQueryValueEx(hkey, TEXT(.SQLPWD.), NULL,
NULL, (LPBYTE)password64, &size64);
Base64Decode(password64, size64, (BYTE*)password, &size);
rc = SQLConnect(*hdbc, server, SQL_NTS, uid,
SQL_NTS, password, SQL_NTS);
...
password64
값을 읽고 값이 base64로 인코딩되었다는 것을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 접근 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
01 RECORDX.
05 UID PIC X(10).
05 PASSWORD PIC X(10).
05 LEN PIC S9(4) COMP.
...
EXEC CICS
READ
FILE('CFG')
INTO(RECORDX)
RIDFLD(ACCTNO)
...
END-EXEC.
CALL "g_base64_decode_inplace" using
BY REFERENCE PASSWORD
BY REFERENCE LEN
ON EXCEPTION
DISPLAY "Requires GLib library" END-DISPLAY
END-CALL.
EXEC SQL
CONNECT :UID
IDENTIFIED BY :PASSWORD
END-EXEC.
...
CFG
에 액세스할 수 있는 모든 사용자는 암호 값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
file, _ := os.Open("config.json")
decoder := json.NewDecoder(file)
decoder.Decode(&values)
password := base64.StdEncoding.DecodeString(values.Password)
request.SetBasicAuth(values.Username, password)
...
config.json
에 액세스할 수 있는 모든 사용자는 password
의 값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 접근 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
Properties prop = new Properties();
prop.load(new FileInputStream("config.properties"));
String password = Base64.decode(prop.getProperty("password"));
DriverManager.getConnection(url, usr, password);
...
config.properties
에 액세스할 수 있는 모든 사용자는 password
값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
String username = new String(Base64.decode(credentials[0], DEFAULT));
String password = new String(Base64.decode(credentials[1], DEFAULT));
handler.proceed(username, password);
}
});
...
...
obj = new XMLHttpRequest();
obj.open('GET','/fetchusers.jsp?id='+form.id.value,'true','scott','tiger');
...
plist
파일에서 암호를 읽고, 암호로 보호되는 파일의 압축을 풀 때 이 암호를 사용합니다.
...
NSDictionary *dict= [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Config" ofType:@"plist"]];
NSString *encoded_password = [dict valueForKey:@"encoded_password"];
NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:encoded_password options:0];
NSString *decodedString = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding];
[SSZipArchive unzipFileAtPath:zipPath toDestination:destPath overwrite:TRUE password:decodedString error:&error];
...
Config.plist
파일에 액세스할 수 있는 모든 사용자는 encoded_password
의 값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다.
...
$props = file('config.properties', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$password = base64_decode($props[0]);
$link = mysql_connect($url, $usr, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
...
config.properties
에 액세스할 수 있는 모든 사용자는 password
값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
props = os.open('config.properties')
password = base64.b64decode(props[0])
link = MySQLdb.connect (host = "localhost",
user = "testuser",
passwd = password,
db = "test")
...
config.properties
에 액세스할 수 있는 모든 사용자는 password
값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
require 'pg'
require 'base64'
...
passwd = Base64.decode64(ENV['PASSWD64'])
...
conn = PG::Connection.new(:dbname => "myApp_production", :user => username, :password => passwd, :sslmode => 'require')
PASSWD64
의 값을 읽고 해당 값이 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.
...
val prop = new Properties();
prop.load(new FileInputStream("config.properties"));
val password = Base64.decode(prop.getProperty("password"));
DriverManager.getConnection(url, usr, password);
...
config.properties
에 액세스할 수 있는 모든 사용자는 password
의 값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 접근 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.plist
파일에서 암호를 읽고, 암호로 보호되는 파일의 압축을 풀 때 이 암호를 사용합니다.
...
var myDict: NSDictionary?
if let path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist") {
myDict = NSDictionary(contentsOfFile: path)
}
if let dict = myDict {
let password = base64decode(dict["encoded_password"])
zipArchive.unzipOpenFile(zipPath, password:password])
}
...
Config.plist
파일에 액세스할 수 있는 모든 사용자는 encoded_password
의 값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다.
...
root:qFio7llfVKk.s:19033:0:99999:7:::
...
...
...
Private Declare Function GetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long
...
Dim password As String
...
password = StrConv(DecodeBase64(GetPrivateProfileString("MyApp", "Password", _
"", value, Len(value), _
App.Path & "\" & "Config.ini")), vbUnicode)
...
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=scott;Passwd=" & password &";"
...
Config.ini
에 액세스할 수 있는 모든 사용자는 Password
값을 읽고 base64로 인코딩된 값임을 쉽게 알 수 있습니다. 비양심적인 직원이 이 정보에 대한 액세스 권한을 갖게 되면 이를 사용하여 시스템에 침입할 수 있습니다.