下記のコード スニペットに基づくと、「filename」変数は次のどの攻撃に対して脆弱ですか? import os filename = input("Enter the file name:") path = "/var/www/html/files/" + filename content = "" with open(path, 'r') as file: content = file.read() print("File content:\n", content)
正解: A
The code snippet is a Python script that takes user input for a filename, constructs a path by concatenating it with /var/www/html/files/, reads the file content, and prints it. The vulnerability arises because the filename variable is directly used in the path without sanitization or validation, allowing an attacker to manipulate it. * Path Traversal Vulnerability: An attacker can input a value like ../../etc/passwd to navigate outside the intended /var/www/html/files/ directory and access sensitive system files (e.g., /etc/passwd). Since the open() function will attempt to access the resulting path, this is a clear case of Path Traversal if the application runs with sufficient permissions. * Remote Code Execution (RCE): RCE would require the ability to execute arbitrary code, which is not directly possible here. The script only reads files, not executes them, unless the file contains executable code and the server interprets it (e.g., a PHP file on a web server),but this is not implied by the code alone. * Option A ("Path Traversal"): Correct, as the lack of input validation makes the code vulnerable to Path Traversal attacks. * Option B ("Remote Code Execution"): Incorrect, as the code does not execute the file content; it only reads it. * Option C ("Both A and B"): Incorrect, as RCE is not applicable here. * Option D ("None of the above"): Incorrect, as Path Traversal is a valid vulnerability. The correct answer is A, aligning with the CAP syllabus under "Path Traversal Attacks" and "Input Validation."References: SecOps Group CAP Documents - "Path Traversal Vulnerabilities," "Input Sanitization," and "OWASP Top 10 (A05:2021 - Security Misconfiguration)" sections.
Null Byte Injection is a vulnerability where a null byte character (\0 or ASCII 0) is injected into user-supplied input to manipulate application behavior, often bypassing filters or terminating strings prematurely in languages like C or C++ that rely on null-terminated strings. In web applications, this is typically encoded in URLs using percent-encoding (e.g., %xx, where xx is the hexadecimal value). The ASCII value of a null byte is 0, which is represented as %00 in URL encoding. * Option A ("%01"): Represents the ASCII character with value 1 (Start of Heading), not a null byte. * Option B ("%10"): Represents the ASCII character with value 16 (Data Link Escape), not a null byte. * Option C ("%25"): Represents the % character itself (ASCII 37), not a null byte. * Option D ("%00"): Represents the null byte (ASCII 0), which is the correct URL-encoded form used in Null Byte Injection attacks. The correct answer is D, aligning with the CAP syllabus under "Injection Attacks" and "Input Validation Bypasses."References: SecOps Group CAP Documents - "Null Byte Injection," "URL Encoding," and "OWASP Injection Prevention" sections.
A Dependency Confusion Attack occurs when an attacker uploads a malicious package with the same name as a private package to a public package repository (e.g., npm, PyPI), causing a package manager to prioritize the malicious public package over the intended private one due to misconfiguration or version precedence. To identify potential private packages for such an attack, attackers analyze dependency configuration files that list the application's dependencies. * Option A ("package.json"): This file is used by npm (Node.js package manager) to define dependencies for JavaScript projects. It lists package names and versions, making it a prime target for identifying private packages that might be targeted in a dependency confusion attack. * Option B ("requirements.txt"): This file is used by pip (Python package manager) to define dependencies for Python projects. It similarly lists package names and versions, making it another target for identifying private packages. * Option C ("Both A and B"): Correct, as both package.json (JavaScript/Node.js) and requirements.txt (Python) are dependency configuration files that can reveal private package names, which an attacker might exploit in a dependency confusion attack. * Option D ("None of the above"): Incorrect, as both files are relevant. The correct answer is C, aligning with the CAP syllabus under "Supply Chain Attacks" and "Dependency Management."References: SecOps Group CAP Documents - "Dependency Confusion Attacks," "Software Supply Chain Security," and "OWASP Dependency-Check Guide" sections.
CAP-JPN 試験問題 19
以下のスクリーンショットでは、攻撃者はどの脆弱性を悪用しようとしていますか? POST /dashboard HTTP/1.1 Host: example.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) rv:107.0) Gecko/20100101 Firefox/107.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 Accept-Language: en-GB,en;q=0.5 Accept-Encoding: gzip, deflate Upgrade-Insecure-Requests: 1 Sec-Fetch-Dest: document Sec-Fetch-Mode: navigate Sec-Fetch-Site: none Sec-Fetch-User: ?1 Cookie: JSESSIONID=7576572ce164646de967c759643d53031 Te: trailers Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 81 xml_foo=<ENTITY example SYSTEM "file:///etc/passwd">]><foo>&example;</foo> <!DOCTYPE foo [<!ENTITY example SYSTEM "file:///etc/passwd">]><foo>&example;</foo> <foo>&example;</foo> <title>Project Meeting</title> <time>1200</time> <location>changed example</location> </body>
正解: D
The request is a POST to /dashboard with a payload containing XML data, specifically an xml_foo parameter with a <!DOCTYPE> declaration and an XML entity (<!ENTITY example SYSTEM "file:///etc/passwd">). Let's analyze the vulnerability: * The payload defines an XML External Entity (XXE) with <!ENTITY example SYSTEM "file:///etc /passwd">, which instructs the XML parser to fetch the contents of /etc/passwd (a sensitive system file) and include it in the &example; reference. The XML then includes <foo>&example;</foo>, which would expand to the contents of /etc/passwd if the parser processes the entity. * This is a classicXML External Entity (XXE) Attack, where an attacker exploits an XML parser's ability to process external entities to access unauthorized resources (e.g., local files, internal network services) or cause denial-of-service. If the application's XML parser is misconfigured to allow external entity resolution, this attack can disclose sensitive data like /etc/passwd. * Option A ("Path Traversal Attack"): Incorrect. Path Traversal involves manipulating file paths (e.g., ../../etc/passwd) to access unauthorized files. While the attack aims to access /etc/passwd, it does so via XML entity resolution, not path traversal. * Option B ("Server Side Template Injection"): Incorrect. SSTI (Server-Side Template Injection) involves injecting template expressions (e.g., {{7*7}}) into a server-side template engine. The payload here is XML, not a template expression, and targets XML parsing, not a template engine. * Option C ("XML Bomb Attack"): Incorrect. An XML Bomb (or Billion Laughs attack) involves recursive entity expansion to cause denial-of-service (e.g., <!ENTITY a "&b;&b;"> <!ENTITY b "lol" >), leading to exponential growth in memory usage. This payload defines a single external entity to fetch a file, not a recursive expansion, so it's not an XML Bomb. * Option D ("XML External Entity Attack"): Correct, as the payload exploits XXE by defining an external entity to access /etc/passwd. The correct answer is D, aligning with the CAP syllabus under "XML External Entity (XXE) Attacks" and "OWASP Top 10 (A04:2021 - Insecure Design)."References: SecOps Group CAP Documents - "XXE Vulnerabilities," "XML Parsing Security," and "OWASP XXE Prevention Cheat Sheet" sections.
CAP-JPN 試験問題 20
次の Google Dork のうち、victim-app.com のディレクトリ リストを見つけるために使用できるものはどれですか?
正解: C
Google Dorks are advanced search operators used to find specific information or vulnerabilities on the web. Directory listing vulnerabilities occur when a web server exposes the contents of a directory (e.g., file names, paths) due to misconfiguration. The operators intitle: and intext: are used to search for specific terms in the title or body of web pages, respectively, combined with site: to limit the search to a specific domain. * Option A ("intitle:'Index of' site:victim-app.com"): Correct, as intitle:"Index of" targets pages with "Index of" in the title, a common indicator of directory listings, and site:victim-app.com restricts the search to that domain. * Option B ("intext:'Index of' site:victim-app.com"): Correct, as intext:"Index of" searches for "Index of" within the page content, another reliable indicator of directory listings, combined with the domain restriction. * Option C ("Both A and B"): Correct, as both intitle: and intext: can effectively identify directory listings, making this the most comprehensive answer. * Option D ("None of the above"): Incorrect, as both A and B are valid Google Dorks for this purpose. The correct answer is C, aligning with the CAP syllabus under "Reconnaissance Techniques" and "Google Dorking."References: SecOps Group CAP Documents - "Information Gathering," "Google Hacking," and "OWASP Testing Guide" sections.