Docsity

Certified API Pentester CAPIPen Exam, Exams of Technology

Toggle sidebar
bg1
Certified API Pentester CAPIPen Exam
**Question 1. Which of the following best describes passive API reconnaissance?**
A) Sending crafted payloads to discover hidden endpoints
B) Using OSINT sources such as GitHub and Shodan to locate publicly exposed APIs
C) Performing brute‑force attacks on authentication endpoints
D) Injecting malicious code into API parameters
Answer: B
Explanation: Passive reconnaissance relies on publicly available data (e.g., search engines, code
repositories) without interacting directly with the target, unlike active techniques that send
traffic.
**Question 2. When analyzing an OpenAPI (Swagger) definition, which element lists the
available HTTP methods for a given path?**
A) components
B) servers
C) paths
D) security
Answer: C
Explanation: The `paths` object in a Swagger file maps each endpoint to the HTTP methods
(GET, POST, etc.) that are supported.
**Question 3. Which tool is commonly used for automated API endpoint discovery by fuzzing
directory names?**
A) Nmap
B) ffuf
C) Wireshark
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Certified API Pentester CAPIPen Exam and more Exams Technology in PDF only on Docsity!

Question 1. Which of the following best describes passive API reconnaissance? A) Sending crafted payloads to discover hidden endpoints B) Using OSINT sources such as GitHub and Shodan to locate publicly exposed APIs C) Performing brute‑force attacks on authentication endpoints D) Injecting malicious code into API parameters Answer: B Explanation: Passive reconnaissance relies on publicly available data (e.g., search engines, code repositories) without interacting directly with the target, unlike active techniques that send traffic. Question 2. When analyzing an OpenAPI (Swagger) definition, which element lists the available HTTP methods for a given path? A) components B) servers C) paths D) security Answer: C Explanation: The paths object in a Swagger file maps each endpoint to the HTTP methods (GET, POST, etc.) that are supported. Question 3. Which tool is commonly used for automated API endpoint discovery by fuzzing directory names? A) Nmap B) ffuf C) Wireshark

D) Metasploit Answer: B Explanation: ffuf (Fuzz Faster U Fool) can brute‑force directories and files, making it suitable for discovering hidden API routes. Question 4. A subdomain enumeration technique that reveals “dev‑api.example.com” is an example of: A) Passive reconnaissance B) Active credential stuffing C) Subdomain takeover D) Subdomain enumeration Answer: D Explanation: Enumerating subdomains discovers additional service endpoints like development APIs, often using DNS brute‑forcing or certificate transparency logs. Question 5. In a SOAP‑based web service, which file type provides a machine‑readable description of available operations? A) WSDL B) JSON C) GraphQL schema D) RAML Answer: A Explanation: WSDL (Web Services Description Language) describes SOAP operations, messages, and data types.

C) Using a dictionary attack against an admin account only D) Exploiting a known default credential in the API documentation Answer: A Explanation: Password spraying tries a common password across many accounts to avoid lockouts, unlike traditional brute‑force which targets one account intensively. Question 9. An attacker modifies the alg header of a JWT from RS256 to HS256 and supplies the original public key as the HMAC secret. This demonstrates: A) Token replay B) Algorithm confusion attack C) Token expiration bypass D) Session fixation Answer: B Explanation: Changing the algorithm and reusing the public key as a secret tricks the server into verifying the token with a weaker HMAC, allowing forgery. Question 10. Which HTTP response header, when misconfigured, can enable a CORS bypass attack? A) X-Content-Type-Options B) Access-Control-Allow-Origin C) Strict-Transport-Security D) Content-Security-Policy Answer: B

Explanation: An overly permissive Access-Control-Allow-Origin (e.g., * or reflecting the request origin) allows malicious sites to read API responses via browsers. Question 11. In the context of SSRF, which internal service is frequently targeted to obtain metadata on cloud platforms? A) 169.254.169. B) 127.0.0. C) 10.0.0. D) 192.168.0. Answer: A Explanation: The link‑local address 169.254.169.254 hosts metadata services on AWS, GCP, Azure, and can leak credentials when accessed via SSRF. Question 12. Which of the following GraphQL queries is used to enumerate the entire schema? A) { __schema { types { name } } } B) { users { id name } } C) mutation { login(username:"",password:"") } D) { __type(name:"User") { fields { name } } } Answer: A Explanation: The introspection query { __schema { types { name } } } returns all types defined in the GraphQL schema, useful for mapping the API. Question 13. A SOAP request contains an XML Signature Wrapping (XSW) payload. Which security control can mitigate this attack? A) Enforcing strict CORS policies

Explanation: The <!ENTITY> declaration defines an external entity that can be resolved by the parser, enabling file reads or internal network scans. Question 16. Which of the following response headers reveals that a server is running Node.js with Express? A) Server: Apache/2.4. B) X-Powered-By: Express C) X-AspNet-Version: 4.0. D) X-Backend-Server: PHP/7. Answer: B Explanation: The X-Powered-By: Express header is added by the Express framework, indicating a Node.js environment. Question 17. In a JWT, the exp claim is used to: A) Identify the issuer of the token B) Store the user’s role C) Indicate the token’s expiration time D) Provide a nonce for replay protection Answer: C Explanation: The exp (expiration) claim defines the Unix timestamp after which the token must be considered invalid. Question 18. Which of the following is a typical mitigation for IDOR vulnerabilities in REST APIs? A) Encrypt all request bodies

B) Use UUIDs that are not guessable and enforce server‑side ownership checks C) Disable HTTPS D) Allow any user to modify any resource Answer: B Explanation: Using non‑sequential, hard‑to‑guess identifiers (e.g., UUIDs) combined with proper authorization checks prevents attackers from enumerating resources. Question 19. A developer implements token revocation by deleting the JWT from a database after logout. Which flaw might still allow token reuse? A) The token’s signature is never verified B) The JWT has no exp claim C) The server does not check the revocation list on each request D) The token is stored in a cookie without the Secure flag Answer: C Explanation: If the server fails to consult the revocation list when validating each request, a previously revoked token can still be accepted. Question 20. Which of the following is a characteristic of a Server‑Side Template Injection (SSTI) payload? A) {{7*7}} in a Jinja2 template B) ; rm - rf / in a shell command C) <script>alert(1)</script> in HTML D) SELECT * FROM users WHERE id=1 in SQL Answer: A

B) Information disclosure C) Rate limiting D) Input validation Answer: B Explanation: Exposing internal error details gives attackers insight into the application’s internals, aiding further exploitation. Question 24. Which of the following best describes a “refresh token” in OAuth 2.0? A) A token that grants immediate access to protected resources without further checks B) A short‑lived token used to obtain a new access token after the original expires C) A token that contains user credentials in plain text D) A token that is only valid for a single request Answer: B Explanation: Refresh tokens are long‑lived and allow clients to request new access tokens without re‑authenticating the user. Question 25. In the context of API security testing, the term “fuzzing” refers to: A) Systematically sending malformed or random data to discover unexpected behavior B) Encrypting all traffic with TLS C) Performing a full code review of the source repository D) Conducting social engineering against developers Answer: A Explanation: Fuzzing involves feeding unexpected inputs to an API to trigger crashes, errors, or security flaws.

Question 26. Which of the following is a common mitigation against HTTP Parameter Pollution (HPP) attacks? A) Allowing duplicate query parameters B) Normalizing request parameters to a single value on the server side C) Disabling TLS D) Using only GET requests Answer: B Explanation: Properly handling duplicate parameters (e.g., taking the first or last value) prevents attackers from manipulating the request processing. Question 27. An API uses the X-Forwarded-For header to determine the client IP address. Which attack can abuse this header? A) Cross‑Site Scripting (XSS) B) IP Spoofing for rate‑limit bypass C) SQL Injection D) CSRF Answer: B Explanation: By setting a forged X-Forwarded-For value, an attacker can appear to originate from a trusted IP, potentially bypassing IP‑based throttling or blacklists. Question 28. Which of the following is the most reliable way to ensure that a JWT cannot be tampered with when using asymmetric signing? A) Store the private key on the client side B) Use the none algorithm

Explanation: Rate limiting caps request frequency to mitigate abuse, DoS attacks, and credential‑stuffing attempts. Question 31. An attacker sends a request to an API endpoint that triggers an internal DNS lookup to internal.service.local. This is an example of: A) DNS Rebinding B) Server‑Side Request Forgery (SSRF) C) DNS Cache Poisoning D) Man‑in‑the‑Middle Answer: B Explanation: SSRF forces the server to initiate outbound connections, such as DNS queries, to internal resources not directly reachable by the attacker. Question 32. Which of the following is a recommended practice when storing JWT secrets for HS256 signing? A) Hard‑code the secret in source code B) Use a strong, randomly generated secret and store it in a secrets manager C) Use the same secret for all environments (dev, test, prod) D) Store the secret in a publicly accessible Git repository Answer: B Explanation: Secrets should be strong, random, and managed securely (e.g., Vault, AWS Secrets Manager) to prevent brute‑force attacks. Question 33. In a RESTful API, which HTTP method should be used to partially update a resource? A) PUT

B) POST

C) PATCH

D) DELETE

Answer: C Explanation: PATCH applies partial modifications, whereas PUT replaces the entire resource representation. Question 34. Which of the following techniques can be used to bypass a poorly implemented API key check that only looks for the key in a query parameter? A) Include the key in the Authorization header instead B) Use a different HTTP method C) Place the API key in a JSON body field that the server does not inspect D) None of the above – the check cannot be bypassed Answer: C Explanation: If the server only validates the query string, sending the key elsewhere (e.g., in the body) may allow the request to proceed without authentication. Question 35. Which of the following is a sign that an API endpoint is vulnerable to NoSQL injection? A) The endpoint only accepts XML payloads B) Error messages reveal the underlying MongoDB query syntax C) The API returns a 301 redirect for all requests D) The endpoint enforces strict schema validation Answer: B

B) Change the Accept header to application/xml and provide an XML body with an external entity C) Use a GET request with a query string containing <!ENTITY> D) XXE cannot affect JSON APIs Answer: B Explanation: If the server accepts XML when requested via the Accept header, an attacker can supply an XML payload with an external entity to trigger XXE. Question 39. Which of the following is a recommended practice for securing GraphQL endpoints? A) Disable introspection in production environments B) Allow unlimited query depth C) Accept queries via GET requests only D) Expose the schema publicly without authentication Answer: A Explanation: Disabling introspection prevents attackers from automatically discovering the full schema, reducing the attack surface. Question 40. A web API uses the SameSite=Lax attribute on its session cookie. Which type of attack is this primarily intended to mitigate? A) Cross‑Site Scripting (XSS) B) Cross‑Site Request Forgery (CSRF) C) SQL Injection D) Server‑Side Request Forgery (SSRF)

Answer: B Explanation: SameSite=Lax restricts cookie sending on cross‑site sub‑requests, reducing the risk of CSRF attacks. Question 41. Which of the following is the most effective way to mitigate command injection in an API that executes shell commands based on user input? A) Encode user input in Base64 before execution B) Use parameterized APIs or language‑specific safe execution functions instead of concatenating strings C) Increase the timeout for command execution D) Log all commands to a file Answer: B Explanation: Avoiding string concatenation and using safe APIs (e.g., execFile, prepared statements) prevents malicious input from being interpreted as commands. Question 42. When analyzing an API’s error responses, you notice that HTTP 500 responses contain the full stack trace. What is the best remediation? A) Change the status code to 200 B) Remove detailed error information from responses and log it internally C) Disable all error handling D) Return the stack trace only to authenticated users Answer: B Explanation: Suppressing internal details from external responses prevents information leakage while still allowing developers to debug via internal logs.

D) The server responds with “Method Not Allowed” Answer: B Explanation: Successful retrieval of files outside the intended directory via ../ patterns confirms a traversal vulnerability. Question 46. A developer implements token revocation by storing a blacklist of JWT IDs (jti). Which mistake could render this approach ineffective? A) Using a sufficiently long expiration time for tokens B) Not checking the blacklist on every request C) Storing the blacklist in memory only D) Using RSA signatures Answer: B Explanation: If the server fails to verify the blacklist for each request, revoked tokens will still be accepted. Question 47. Which of the following best describes a “refresh token reuse” attack? A) An attacker uses a stolen refresh token to obtain new access tokens repeatedly because the server does not rotate or invalidate it after use B) The client reuses the same access token for multiple APIs C) The refresh token is sent in the URL query string D) The refresh token is stored in a cookie without HttpOnly Answer: A Explanation: If a refresh token is not revoked or rotated after use, an attacker can continuously generate new access tokens.

Question 48. Which of the following is the most appropriate HTTP status code to return when a request violates a rate‑limit policy? A) 400 Bad Request B) 401 Unauthorized C) 403 Forbidden D) 429 Too Many Requests Answer: D Explanation: 429 explicitly signals that the client has sent too many requests in a given time frame. Question 49. When performing a security assessment of a SOAP service, you notice that the SOAPAction header is optional. Which risk does this present? A) Increased latency B) Potential for XML injection attacks because the server may process unexpected actions C) Reduced compatibility with older clients D) None; the header is irrelevant Answer: B Explanation: If the server does not strictly validate SOAPAction, attackers may craft malicious payloads that the service processes unintentionally. Question 50. Which of the following is a recommended way to protect an API that uses JWTs from replay attacks? A) Include a jti (JWT ID) claim and store used IDs in a cache to reject duplicates B) Set the token expiration (exp) to several days