Decoder
및 Encoding
클래스의 GetChars
메서드와 .NET Framework의 Encoder
및 Encoding
클래스의 GetBytes
메서드는 문자 및 바이트 배열에 대해 내부적으로 포인터 산술을 수행하여 문자 범위를 바이트 범위로 변환하거나 그 반대로 수행합니다.
out.println("x = " + encoder.encodeForJavaScript(input) + ";");
...
unichar ellipsis = 0x2026;
NSString *myString = [NSString stringWithFormat:@"My Test String%C", ellipsis];
NSData *asciiData = [myString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *asciiString = [[NSString alloc] initWithData:asciiData encoding:NSASCIIStringEncoding];
NSLog(@"Original: %@ (length %d)", myString, [myString length]);
NSLog(@"Best-fit-mapped: %@ (length %d)", asciiString, [asciiString length]);
// output:
// Original: My Test String... (length 15)
// Best-fit-mapped: My Test String... (length 17)
...
...
let ellipsis = 0x2026;
let myString = NSString(format:"My Test String %C", ellipsis)
let asciiData = myString.dataUsingEncoding(NSASCIIStringEncoding, allowLossyConversion:true)
let asciiString = NSString(data:asciiData!, encoding:NSASCIIStringEncoding)
NSLog("Original: %@ (length %d)", myString, myString.length)
NSLog("Best-fit-mapped: %@ (length %d)", asciiString!, asciiString!.length)
// output:
// Original: My Test String ... (length 16)
// Best-fit-mapped: My Test String ... (length 18)
...
MAX_PATH
바이트 이상인 버퍼가 필요하지만 각 함수에 대한 설명을 개별적으로 확인하는 것이 좋습니다. 버퍼가 조작 결과를 저장할 만큼 크지 않으면 buffer overflow가 발생할 수 있습니다.
char *createOutputDirectory(char *name) {
char outputDirectoryName[128];
if (getCurrentDirectory(128, outputDirectoryName) == 0) {
return null;
}
if (!PathAppend(outputDirectoryName, "output")) {
return null;
}
if (!PathAppend(outputDirectoryName, name)) {
return null;
}
if (SHCreateDirectoryEx(NULL, outputDirectoryName, NULL)
!= ERROR_SUCCESS) {
return null;
}
return StrDup(outputDirectoryName);
}
output\<name>
"인 디렉터리를 만들고 해당 이름의 힙(heap) 할당 복사본을 반환합니다. 현재 디렉터리 및 이름 매개 변수의 값 대부분에 대해서 이 함수는 올바로 동작합니다. 하지만 name
매개 변수가 특히 길 경우, 두 번째 PathAppend()
호출은 MAX_PATH
바이트보다 작은 outputDirectoryName
버퍼에 오버플로를 일으킬 수 있습니다.umask()
의 인수로 지정된 마스크와 chmod()
의 인수를 혼동하는 경우가 많습니다.umask()
man page는 다음 false 문으로 시작합니다.chmod()
사용법과 일치하는 것 같지만 다음과 같이 umask()
의 실제 동작은 그 반대입니다. umask()
는 umask를 ~mask & 0777
로 설정합니다.umask()
man page는 다음과 같이 umask()
의 정확한 사용법까지 설명합니다.open()
이 새로 생성한 파일에 초기 파일 권한을 설정할 때 사용합니다. 구체적으로 umask의 권한은 open(2)
의 모드 인수에 따라 비활성화됩니다. 예를 들면, 일반적인 umask 기본값 022는 모드가 0666으로 지정되는 일반적인 경우 0666 & ~022 = 0644 = rw-r--r-- 권한으로 새 파일을 생성합니다."
...
struct stat output;
int ret = stat(aFilePath, &output);
// error handling omitted for this example
struct timespec accessTime = output.st_atime;
...
umask()
의 인수로 지정된 마스크와 chmod()
의 인수를 혼동하는 경우가 많습니다.umask()
man page는 다음 false 문으로 시작합니다.chmod()
사용법과 일치하는 것 같지만 다음과 같이 umask()
의 실제 동작은 그 반대입니다. umask()
는 umask를 ~mask & 0777
로 설정합니다.umask()
man page는 다음과 같이 umask()
의 정확한 사용법까지 설명합니다.transactionId
를 씁니다.
...
//get the documents directory:
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
//make a file name to write the data to using the documents directory:
let fileName = NSString(format:"%@/tmp_activeTrans.txt", documentsPath)
// write data to the file
let transactionId = "TransactionId=12341234"
transactionId.writeToFile(fileName, atomically:true)
...
posted
개체에 할당합니다. FileUpload
는 System.Web.UI.HtmlControls.HtmlInputFile
형식입니다.
HttpPostedFile posted = FileUpload.PostedFile;
@Controller
public class MyFormController {
...
@RequestMapping("/test")
public String uploadFile (org.springframework.web.multipart.MultipartFile file) {
...
} ...
}
<?php
$udir = 'upload/'; // Relative path under Web root
$ufile = $udir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $ufile)) {
echo "Valid upload received\n";
} else {
echo "Invalid upload rejected\n";
} ?>
from django.core.files.storage import default_storage
from django.core.files.base import File
...
def handle_upload(request):
files = request.FILES
for f in files.values():
path = default_storage.save('upload/', File(f))
...
file
형식의 <input>
태그는 프로그램이 파일 업로드를 허용함을 표시합니다.
<input type="file">
root
권한으로 실행되는 프로그램은 수없이 많은 Unix 보안 문제를 일으킵니다. 모든 종류의 보안 문제에 대해 권한 있는 프로그램을 신중하게 검토하는 일도 시급하지만 간과한 취약점이 일으킬 수 있는 피해 규모를 줄이기 위해 최대한 빨리 권한 있는 프로그램을 권한 없는 상태로 되돌리는 것도 중요합니다.root
사용자가 아닌 사용자에서 다른 사용자로 전환하려 할 때 두드러집니다. root
로 실행될 때 시그널 처리기 또는 하위 프로세스가 실행되는 경우 시그널 처리기나 하위 프로세스는 루트 권한으로 실행됩니다. 공격자는 이 높은 권한을 이용하여 더 큰 피해를 줄 수 있습니다.root
권한으로 실행된 프로그램은 무수한 Unix 보안 재해를 일으켰습니다. 모든 종류의 보안 문제에 대해 권한 있는 프로그램을 신중하게 검토해야 하지만, 간과된 취약성이 야기할 수 있는 피해를 최소화하기 위해 권한 있는 프로그램에서 최대한 빨리 권한을 박탈하는 것도 그에 못지 않게 중요합니다.root
사용자가 아닌 한 사용자에서 다른 사용자로 전환하는 경우 특히 두드러집니다.root
로 실행 중인 경우 신호 처리기 또는 하위 프로세스는 루트 권한으로 작동합니다. 공격자는 이러한 승격된 권한을 활용하여 추가적인 손상을 입힐 수 있습니다.root
권한으로 실행되는 프로그램은 수없이 많은 Unix 보안 문제를 일으킵니다. 모든 종류의 보안 문제에 대해 권한 있는 프로그램을 신중하게 검토하는 일도 시급하지만 간과한 취약점이 일으킬 수 있는 피해 규모를 줄이기 위해 최대한 빨리 권한 있는 프로그램을 권한 없는 상태로 되돌리는 것도 중요합니다.root
사용자가 아닌 사용자에서 다른 사용자로 전환하려 할 때 두드러집니다.root
로 실행될 때 시그널 처리기 또는 하위 프로세스가 실행되는 경우 시그널 처리기나 하위 프로세스는 루트 권한으로 실행됩니다. 공격자는 이 높은 권한을 이용하여 더 큰 피해를 줄 수 있습니다.root
권한으로 실행되는 프로그램은 수없이 많은 Unix 보안 문제를 일으킵니다. 모든 종류의 보안 문제에 대해 권한 있는 프로그램을 신중하게 검토하는 일도 시급하지만 간과한 취약점이 일으킬 수 있는 피해 규모를 줄이기 위해 최대한 빨리 권한 있는 프로그램을 권한 없는 상태로 되돌리는 것도 중요합니다.root
사용자가 아닌 사용자에서 다른 사용자로 전환하려 할 때 두드러집니다.root
로 실행될 때 시그널 처리기 또는 하위 프로세스가 실행되는 경우 시그널 처리기나 하위 프로세스는 루트 권한으로 실행됩니다. 공격자는 이 높은 권한을 이용하여 더 큰 피해를 줄 수 있습니다.sun.misc.Unsafe
의 기능을 사용합니다. 이 클래스의 모든 기능은 기본적으로 사용하기에 안전하지 않으며 리플렉션을 통해서만 액세스할 수 있습니다.sun.misc.Unsafe
클래스는 안전하지 않은 하위 수준 작업 수행용이며 개발자는 사용하면 안 됩니다.Unsafe
클래스는 신뢰할 수 있는 코드에서만 사용해야 하며, 일반적으로는 리플렉션을 통해 액세스해야 합니다. 이 클래스는 시스템을 손상시키거나 힙 메모리를 수동으로 할당하는 데 사용될 수 있으므로, 적절하게 취급하지 않으면 시스템에 심각한 영향을 줄 수 있기 때문입니다. sun.misc.Unsafe
와 관련된 모든 기능을 철저하게 검토 및 테스트하여 결함이 없는지 확인해야 합니다.Value Stack
컨텍스트의 EL 식을 평가할 수 있도록 합니다. 확인되지 않은 식을 Value Stack
과 비교하여 평가할 수 있게 하면 공격자가 액세스하여 시스템 변수를 수정하거나 임의의 코드를 실행할 수 있게 됩니다.
OgnlContext ctx = new OgnlContext();
String expression = request.getParameter("input");
Object expr = Ognl.parseExpression(expression);
Object value = Ognl.getValue(expr, ctx, root);
System.out.println("Value: " + value);
(#rt = @java.lang.Runtime@getRuntime(),#rt.exec("calc.exe"))
%{expr}
)을 사용합니다. 첫 번째 평가의 결과를 제어하는 공격자는 두 번째 OGNL 평가에서 평가될 식을 제어하고 임의의 OGNL 식을 삽입할 수 있습니다.redirectAction
결과는 매개 변수를 두 번 평가하는 것으로 알려져 있습니다. 이 경우 actionName
매개 변수의 강제 OGNL 식의 결과가 redirect
요청 매개 변수를 제공하여 공격자에 의해 제어될 수 있습니다.
...
<action name="index" class="com.acme.MyAction">
<result type="redirectAction">
<param name="actionName">${#parameters['redirect']}</param>
<param name="namespace">/foo</param>
</result>
</action>
...
%{#parameters['redirect']}
식을 평가하여 OGNL 식으로 평가될 사용자 제어 문자열을 반환하여 공격자가 임의의 OGNL 식을 평가할 수 있도록 합니다.execute()
외의 메서드가 노출될 수 있습니다. "동적 메서드 호출"이 활성화된 경우 !
(느낌표) 문자 또는 method:
접두사를 Action URL에 사용하여 Action의 모든 공개 메서드를 호출할 수 있습니다. Struts 2 버전 2.3.20
에서는 이전에 리플렉션을 기반으로 한 대체 메서드 호출 메커니즘이 OGNL을 대신 사용하도록 바뀌었는데 공격자는 이를 통해 대체 메서드 이름 대신 악성 OGNL 식을 제공할 수 있습니다.debug
요청 매개 변수를 사용하여 트리거할 수 있습니다.console
인 경우 개발자가 서버에서 임의의 OGNL 식을 평가할 수 있는 OGNL 평가 콘솔이 팝업으로 표시됩니다.command
인 경우 개발자는 요청 매개 변수 expression
을 사용하여 평가할 임의의 OGNL 식을 제출할 수 있습니다.xml
은 매개 변수, 컨텍스트, 세션 및 값 스택을 XML 문서로 덤프합니다.browser
는 매개 변수, 컨텍스트, 세션 및 값 스택을 검색 가능한 HTML 문서로 덤프합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
...
DATA: str_dest TYPE c.
str_dest = request->get_form_field( 'dest' ).
response->redirect( str_dest ).
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 읽어들인 URL을 열도록 지시합니다.
...
var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
var strDest:String = String(params["dest"]);
host.updateLocation(strDest);
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수의 URL로 구성된 PageReference
개체를 반환합니다.
public PageReference pageAction() {
...
PageReference ref = ApexPages.currentPage();
Map<String,String> params = ref.getParameters();
return new PageReference(params.get('dest'));
}
Example 1
의 코드가 브라우저를 "http://www.wilyhacker.com"으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
String redirect = Request["dest"];
Response.Redirect(redirect);
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
...
final server = await HttpServer.bind(host, port);
await for (HttpRequest request in server) {
final response = request.response;
final headers = request.headers;
final strDest = headers.value('strDest');
response.headers.contentType = ContentType.text;
response.redirect(Uri.parse(strDest!));
await response.close();
}
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
...
strDest := r.Form.Get("dest")
http.Redirect(w, r, strDest, http.StatusSeeOther)
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
<end-state id="redirectView" view="externalRedirect:#{requestParameters.dest}" />
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 읽어 들인 URL을 열도록 지시합니다.
...
strDest = form.dest.value;
window.open(strDest,"myresults");
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 사용자 브라우저에 지시합니다.
<%
...
$strDest = $_GET["dest"];
header("Location: " . $strDest);
...
%>
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
...
-- Assume QUERY_STRING looks like dest=http://www.wilyhacker.com
dest := SUBSTR(OWA_UTIL.get_cgi_env('QUERY_STRING'), 6);
OWA_UTIL.redirect_url('dest');
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
...
strDest = request.field("dest")
redirect(strDest)
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
...
str_dest = req.params['dest']
...
res = Rack::Response.new
...
res.redirect("http://#{dest}")
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
def myAction = Action { implicit request =>
...
request.getQueryString("dest") match {
case Some(location) => Redirect(location)
case None => Ok("No url found!")
}
...
}
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.requestToLoad
가 원래 URL의 "dest" 매개 변수(있는 경우) 및 http://
스키마를 사용하는 원래 URL을 가리키도록 설정하고, 마지막으로 이 요청을 WKWebView 내에서 로드합니다.
...
let requestToLoad : String
...
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
...
if let urlComponents = NSURLComponents(URL: url, resolvingAgainstBaseURL: false) {
if let queryItems = urlComponents.queryItems as? [NSURLQueryItem]{
for queryItem in queryItems {
if queryItem.name == "dest" {
if let value = queryItem.value {
request = NSURLRequest(URL:NSURL(string:value))
requestToLoad = request
break
}
}
}
}
if requestToLoad == nil {
urlComponents.scheme = "http"
requestToLoad = NSURLRequest(URL:urlComponents.URL)
}
}
...
}
...
...
let webView : WKWebView
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
webView.loadRequest(appDelegate.requestToLoad)
...
Example 1
의 코드가 요청을 시도하고 WKWebView에서 “http://www.wilyhacker.com”을 로드합니다.dest
요청 매개 변수에서 구문 분석한 URL을 열도록 지시합니다.
...
strDest = Request.Form('dest')
HyperLink.NavigateTo strDest
...
Example 1
의 코드가 브라우저를 “http://www.wilyhacker.com”으로 리디렉션합니다.
...
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
...
...
<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"
...