軟體安全性並非安全性軟體。我們關注驗證、Access Control、保密性、加密以及權限管理之類的主題。
12345
。
...
kind: KubeletConfiguration
...
readOnlyPort: 12345
...
default
服務帳戶。對於每個服務帳戶,會自動產生一個 API 存取權杖,並在掛載的目錄中提供該權杖。攻擊者可以使用任何遭入侵容器中的存取權杖來存取保護不足和安全性敏感的服務 API。automountServiceAccountToken
或預設服務帳戶的組態包含 automountServiceAccountToken: true
設定。automountServiceAccountToken
未定義或設定為 true
,如本範例所示,則會為 Pod 的 default
服務帳戶自動掛載 API 認證。範例 2:為 Pod 自動掛載 API 認證,因為
apiVersion: v1
kind: ServiceAccount
metadata:
name: default
namespace: demo-namespace
automountServiceAccountToken: true
...
default
服務帳戶有 automountServiceAccountToken: true
設定,如本範例所示。
apiVersion: v1
kind: Pod
...
spec:
automountServiceAccountToken: true
...
--use-service-account-credentials=true
旗標,所以會在控制器之間共用服務帳戶認證。此旗標會指示 Controller Manager 使用不同的服務帳戶來啟動每個控制器。將其與角色型存取控制 (RBAC) 結合使用時,可確保每個控制器以執行其任務所需的最低權限來執行。--use-service-account-credentials
旗標的情況下啟動一個 Kubernetes Controller Manager。
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 檢查,在該類別的複製方法中也必須存有相同的檢查。否則,複製該類別後,就會略過安全檢查。SecurityManager
檢查,但在 clone()
方法中則沒有此檢查。
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
檢查的可序列化類別必須在其 readObject()
和 readObjectNoData
方法中也執行相同的檢查。readObject()
方法時,不會呼叫該類別正在還原序列化的建構函數。因此,如果可序列化類別中的建構函數存有 SecurityManager
檢查,在 readObject()
與 readObjectNoData()
方式中也必須存有相同的 SecurityManager
檢查。否則,還原序列化該類別後,就會略過安全檢查。SecurityManager
檢查,但在 readObject()
與 readObjectNoData()
方式中則沒有此檢查。
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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
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
,則攻擊者可以透過提供 Empty Password 來檢視受保護的頁面。
...
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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。""
,做為未指定密碼時的預設值。在此案例中,您還需要確認指定引數的數量正確,以確保密碼可傳送到函數。
...
ws.url(url).withAuth("john", "", WSAuthScheme.BASIC)
...
...
let password = ""
let username = "scott"
let con = DBConnect(username, password)
...
Example 1
中的程式碼連線成功,表示資料庫使用者帳戶「scott」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
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
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。null
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
...
var storedPassword:String = null;
var temp:String;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(Utils.verifyPassword(userPassword, storedPassword))
// Access protected resources
...
}
...
readPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 userPassword
而輕易地略過密碼檢查。null
給密碼變數絕對不是個好方法,因為這可能會讓攻擊者略過密碼驗證,或可能指出資源是由空白密碼所保護。null
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
...
string storedPassword = null;
string temp;
if ((temp = ReadPassword(storedPassword)) != null) {
storedPassword = temp;
}
if (Utils.VerifyPassword(storedPassword, userPassword)) {
// Access protected resources
...
}
...
ReadPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 userPassword
而輕易地略過密碼檢查。null
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。null
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
...
string storedPassword = null;
string temp;
if ((temp = ReadPassword(storedPassword)) != null) {
storedPassword = temp;
}
if(Utils.VerifyPassword(storedPassword, userPassword))
// Access protected resources
...
}
...
ReadPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 userPassword
而輕易地略過密碼檢查。null
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。null
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
...
char *stored_password = NULL;
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password))
// Access protected resources
...
}
...
readPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 user_password
而輕易地略過密碼檢查。null
給密碼變數絕對不是個好方法,因為這可能會讓攻擊者略過密碼驗證,或可能指出資源是由空白密碼所保護。null
給密碼變數是不當的做法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。null
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
...
String storedPassword = null;
String temp;
if ((temp = readPassword()) != null) {
storedPassword = temp;
}
if(Utils.verifyPassword(userPassword, storedPassword))
// Access protected resources
...
}
...
readPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 userPassword
而輕易地略過密碼檢查。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
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。null
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
...
NSString *stored_password = NULL;
readPassword(stored_password);
if(safe_strcmp(stored_password, user_password)) {
// Access protected resources
...
}
...
readPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 user_password
而輕易地略過密碼檢查。null
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。null
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
<?php
...
$storedPassword = NULL;
if (($temp = getPassword()) != NULL) {
$storedPassword = $temp;
}
if(strcmp($storedPassword,$userPassword) == 0) {
// Access protected resources
...
}
...
?>
readPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 userPassword
而輕易地略過密碼檢查。null
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。null
。
DECLARE
password VARCHAR(20);
BEGIN
password := null;
END;
null
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。null
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
...
storedPassword = NULL;
temp = getPassword()
if (temp is not None) {
storedPassword = temp;
}
if(storedPassword == userPassword) {
// Access protected resources
...
}
...
getPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 userPassword
而輕易地略過密碼檢查。nil
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由空白密碼所保護。nil
,嘗試讀取已儲存的密碼值,並與使用者提供的值進行比較。
...
@storedPassword = nil
temp = readPassword()
storedPassword = temp unless temp.nil?
unless Utils.passwordVerified?(@userPassword, @storedPassword)
...
end
...
readPassword()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 @userPassword
而輕易地略過密碼檢查。nil
,做為未指定密碼時的預設值。在此案例中,您還需要確認指定引數的數量正確,以確保密碼可傳送到函數。null
給密碼變數是不當的做法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。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()
因為資料庫錯誤或其他問題而無法擷取儲存的密碼,攻擊者就可藉由提供 null
值給 user_password
而輕易地略過密碼檢查。null
給密碼變數絕對不是個好方法,因為會讓攻擊者略過密碼驗證,或指出資源是由 Empty Password 所保護。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」是以 Empty Password 配置,攻擊者可輕易地猜測出此密碼。程式發佈後,需要變更程式碼才可以更新帳戶以使用非 Empty Password。
...
* 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
的值,而且輕鬆地判定此值是以 64 位元為基礎進行編碼的。若心懷不軌的員工擁有此資訊的存取權,則他們可以利用此資訊來進入並破壞系統。
...
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 編碼。若心懷不軌的員工擁有此資訊的存取權,則他們可以利用此資訊來進入並破壞系統。