
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

























Q1. Which security principle states that a user or process should be granted only the minimum permissions necessary to perform its required function? A. Defense in depth B. Least privilege C. Separation of duties D. Fail-safe defaults Answer: B Rationale: Least privilege restricts access rights to the minimum level required for a legitimate task, limiting the blast radius of a compromised account or process. Defense in depth refers to layered controls, separation of duties divides critical functions among multiple actors, and fail-safe defaults means access is denied unless explicitly granted. Q2. In secure design, what does the principle of "fail-safe defaults" mean? A. The system should fail open to preserve availability B. Access should be denied by default unless explicitly allowed C. All errors should be logged with full stack traces D. Default passwords must be changed after installation Answer: B Rationale: Fail-safe defaults means the default state is denial—access is granted only through explicit configuration. Failing open is the
repositories. A .env file that is git-ignored and loaded at runtime keeps secrets out of the codebase. Embedding at build time still bakes the secret into image layers where it can be extracted. Q6. A Flask endpoint accepts age = request.args.get('age') and later uses int(age) without validation. What secure coding principle is violated and what is the fix? A. Input validation; validate that age is digit and in range 0-120 before conversion, return 400 if invalid B. Least privilege; run app as root C. Security by obscurity; hide endpoint URL D. No validation needed because int() will handle it Answer: A Rationale: All external input must be validated for type, range, and format before use. int() on non-numeric raises ValueError, and unvalidated input leads to injection. Q7. Why should Python code avoid using os.system(user_input) and what is the secure alternative? A. os.system invokes shell and allows command injection; use subprocess.run with shell=False and argument list with validation B. os.system is faster so should be used C. os.system prevents injection by default D. Use eval() instead Answer: A Rationale: os.system passes input to the shell, allowing attackers to inject commands. subprocess with shell=False avoids shell interpretation . Q8. A function builds a file path via open('/data/' + filename) where filename comes from user input. What vulnerability and fix? A. Path traversal; use os.path.basename, validate against allowlist, and use os.path.join with realpath check that resolved path starts with allowed base directory B. SQL injection; use parameterized queries C. XSS; use html.escape D. No vulnerability, concatenation is safe Answer: A
Rationale: ../../etc/passwd can escape the intended directory. basename and realpath containment prevent traversal. Q9. Which HTTP response header helps mitigate cross-site scripting by instructing the browser to restrict which sources can execute scripts? A. Access-Control-Allow-Origin B. Content-Security-Policy C. Strict-Transport-Security D. X-Frame-Options Answer: B Rationale: Content-Security-Policy (CSP) restricts the origins from which scripts can be loaded, mitigating XSS. Q10. What does the principle of least privilege mean for a Python API service connecting to a database? A. Service account should have only SELECT, INSERT on needed tables, not DROP or admin rights B. Service should run as root with full DB admin C. All users should share same admin password D. Least privilege means no authentication needed Answer: A Rationale: Limiting database permissions reduces the blast radius if the service is compromised. Q11. A developer disables TLS certificate verification via requests.get(url, verify=False) to fix a development error. Why is this insecure for production? A. Disables protection against man-in-the-middle attacks, allowing an attacker to intercept or modify data B. It makes requests faster and is recommended C. It only affects logging D. It prevents SQL injection Answer: A Rationale: verify=False skips certificate chain validation, enabling MITM attacks. Q12. What is the secure remediation for a hardcoded password string flagged by Bandit (B105)? A. Move the secret to an environment variable or secret manager and
D. Secure API Standard Testing; run only on APIs Answer: A Rationale: SAST analyzes source without running it, ideal early to shift left.
Q16. What is the OWASP API Security Top 10 number-one risk, involving an API endpoint accepting an object identifier and returning the object without checking whether the calling user is authorized? A. Broken Object Level Authorization (BOLA) B. Broken Authentication C. Security Misconfiguration D. Injection Answer: A Rationale: BOLA occurs when an API allows users to retrieve data based on an identifier without verifying permission. Attackers simply iterate IDs to harvest other users' data. Q17. What is the recommended mitigation for BOLA? A. Use sequential integer IDs for simplicity B. Enforce object-level authorization checks on every endpoint that takes an object reference, use unguessable identifiers (UUIDs), and test for BOLA in CI C. Only authenticate users but do not authorize D. Hide the API endpoint URL Answer: B Rationale: Server-side authorization checks must verify that the current user is allowed access to the requested data. UUIDs add obscurity but are not a complete solution. Q18. What is the Task 2 scenario in WGU D385? A. A healthcare records system B. An internal Construction Equipment Rental API (v2.2.0, endpoints
under /api/v1/) suffering unauthorized access attempts and failing authorization logic C. A social media platform D. A banking transaction system Answer: B Rationale: The Task 2 scenario involves securing an internal Construction Equipment Rental API that is experiencing unauthorized access attempts, suspicious input patterns, and failing authorization logic. Q19. What are the evidence files provided with the Task 2 starter? A. Only a Python file B. app_student.py (vulnerable code), task_2_flake8_report.txt (general vulns), task_2_bandit_report.txt (API vulns), network_security_log.txt (attack evidence), penetration_test_report.json (fill-in template) C. Only a Word document D. Only a test script Answer: B Rationale: These files provide the vulnerable code, static analysis reports, attack evidence, and a template for the penetration test report. Q20. What security principles does the Task 2 introduction name that should be explained in the report? A. Only encryption B. Least privilege, defense in depth, encryption, API keys, and OAuth C. Only OAuth D. Only API keys Answer: B Rationale: The task requires explaining how least privilege, defense in depth, encryption, API keys, and OAuth each protect modern APIs. Q21. What is the recommended course textbook to cite in the Task 2 report? A. "Clean Code" by Robert Martin B. "Full Stack Python Security" by Dennis Byrne C. "The Pragmatic Programmer" D. "Design Patterns" by Gang of Four Answer: B
B. Unrestricted Resource Consumption C. Broken Function Level Authorization D. Security Misconfiguration Answer: B Rationale: Without appropriate limits on bandwidth, CPU, and memory, APIs can be exploited for DoS or cost inflation. Q26. What is the mitigation for Server-Side Request Forgery (SSRF) in an API that fetches external URLs? A. Allow any URL provided by the user B. Validate the destination URL against an allowlist, block internal IP ranges, and do not follow redirects to internal addresses C. Use verify=False for speed D. Rely on obscurity Answer: B Rationale: SSRF occurs when an attacker provides a URL like http://localhost/admin to access internal resources. Allowlisting and blocking internal ranges prevent this. Q27. What does API Security Misconfiguration commonly expose? A. Detailed error messages revealing database structures or internal paths B. Only performance metrics C. Only user names D. Nothing; default configurations are always secure Answer: A Rationale: Production APIs showing detailed error messages can reveal database structures or internal paths that attackers can exploit. Q28. What is the risk of inadequate API inventory management? A. Old, vulnerable API versions (e.g., /v1/login) may remain accessible, allowing attackers to bypass protections implemented in newer versions B. It improves security C. It reduces costs D. It has no impact Answer: A Rationale: Maintaining an outdated API endpoint without protection allows attackers to exploit its security flaws.
Q29. What is insecure API consumption? A. Trusting data from third-party APIs without validation B. Consuming too much coffee C. Using OAuth D. Using encryption Answer: A Rationale: Developers who trust third-party API data without validation allow indirect attacks, such as a payment system accepting fake confirmations. Q30. What is the first step in the Task 2 remediation workflow for general vulnerabilities? A. Delete the vulnerable code immediately B. Pick 2 general vulnerabilities from the flake8 report, screenshot the insecure code with line numbers C. Ignore the flake8 report D. Only fix API vulnerabilities Answer: B Rationale: The rubric requires selecting 2 general vulnerabilities from the flake8 report and documenting the insecure code with line numbers. Q31. Why should the original vulnerable code be commented out rather than deleted? A. The evaluator must see before-and-after in the same file—proof you found the exact lines, replaced them securely, and disabled the old path B. To make the file longer C. To confuse the evaluator D. It is required by Python syntax Answer: A Rationale: Commenting out preserves the evidence of remediation in the same file, showing the exact lines found and replaced. Q32. Which two API security vulnerabilities should be selected from the bandit report for Section B? A. Any two from the bandit report B. Only hardcoded passwords C. Only SQL injection
Q36. What must every test function in the Task 2 test script include? A. A print() statement only B. A function name prefixed with test_ and an assert statement C. A return statement D. A try/except block Answer: B Rationale: The rubric requires pytest functions named test_* with assert in every test. Q37. What are the four scaffold test names in test_run.py for Task 2? A. test_general_vuln_1_hardcoded_secrets_remediated, test_general_vuln_2_plaintext_passwords_remediated, test_api_vuln_1_authentication_required, test_api_vuln_2_authorization_enforced B. test_1, test_2, test_3, test_ C. test_sql, test_xss, test_auth, test_authz D. test_general, test_api, test_secure, test_final Answer: A Rationale: These four test names are specified in the scaffold for Task
Q38. What is the purpose of descriptive print() lines in the Task 2 tests? A. To explain each outcome for the console screenshot B. To debug the application C. To slow down execution D. To replace assertions Answer: A Rationale: The rubric requires descriptive print() lines explaining each outcome for the console screenshot (C4). Q39. How many passing-test screenshots are required in Section C? A. 1 B. 2 C. 4 (2 general + 2 API) D. 10 Answer: C
Rationale: The rubric requires four passing-test screenshots: 2 general vulnerability tests + 2 API vulnerability tests. Q40. In pytest, what is the convention for test function names? A. They must end with test B. They must be prefixed with test C. They must be uppercase D. They must contain the word "assert" Answer: B Rationale: pytest discovers test functions by the test_ prefix. Functions named otherwise will not be collected. Q41. How does pytest discover test files? A. Only files named exactly test.py B. All files of the form test_*.py or test.py in the current directory and its subdirectories C. Only files in a tests directory D. Only files with a .test extension Answer: B Rationale: pytest follows standard test discovery rules: files matching test.py or *_test.py are collected. Q42. What does pytest.raises do? A. Asserts that a certain exception is raised B. Skips a test C. Marks a test as failed D. Runs a test multiple times Answer: A Rationale: pytest.raises is a context manager for asserting that code raises a specific exception. Q43. What is the required number of mitigation strategies for EACH of the 4 remediated vulnerabilities in the report (D1)? A. 1 B. 2 C. 3 D. 4 Answer: B
Q48. What is the purpose of the app_student.py file? A. It contains the vulnerable code to be remediated B. It is the solution file C. It is the test script D. It is the report template Answer: A Rationale: app_student.py is the vulnerable code provided in the starter. Q49. What should the fixed application be saved as? A. app_fixed.py B. app_solution.py C. solution.py D. fixed.py Answer: B Rationale: The starter instructs saving the fixed app as app_solution.py. Q50. What is the purpose of the network_security_log.txt file? A. It contains attack evidence B. It contains the test results C. It contains the vulnerable code D. It contains the report template Answer: A Rationale: network_security_log.txt provides attack evidence for the scenario. Q51. Which security principle involves multiple overlapping controls so one failure does not equal compromise? A. Least privilege B. Defense in depth C. Separation of duties D. Fail-safe defaults Answer: B Rationale: Defense in depth uses layered controls to prevent a single point of failure from leading to full compromise. Q52. What does the USERS_DB roles (admin/user/guest) exist to enforce in Task 2? A. Least privilege on endpoints B. Encryption
C. Logging D. Performance Answer: A Rationale: The roles exist to enforce least privilege on API endpoints. Q53. What is the OWASP Top 10? A. A ranked list of the most critical web application security risks B. A list of Python libraries C. A testing framework D. A database management system Answer: A Rationale: OWASP Top 10 is the industry vocabulary for web application vulnerability categories. Q54. In pytest, what is the output when a test fails? A. A detailed failure report showing the assertion and values B. Only "FAILED" C. A blank screen D. A success message Answer: A Rationale: pytest provides rich failure reporting with intermediate values of the assert expression. Q55. What does assert do in a pytest test? A. Verifies test expectations; if the condition is False, the test fails B. Skips the test C. Prints a message D. Returns a value Answer: A Rationale: The assert statement verifies expectations. pytest's advanced assertion introspection reports intermediate values. Q56. What is the recommended approach for explaining each test outcome in the console screenshot? A. Descriptive print() lines B. No explanation needed C. Only the test name D. Only the pass/fail status Answer: A