









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!










◉ COURSE: The three course competencies Answer: 4102.1.1 Evaluates application and network logs; 4102.1. Develops mitigation solutions for vulnerabilities; 4102.1. Configures security authentication for REST APIs ◉ COURSE: Task 1 vs Task 2 in one line each Answer: Task 1: add logging, error handling, assertions, and passing unit tests to the equipment rental app. Task 2: remediate 2 general + 2 API vulnerabilities, write 4 tests proving it, and report on mitigation/validation/exceptions/encryption ◉ COURSE: Course textbook Answer: Full Stack Python Security by Dennis Byrne (cryptography, TLS, attack resistance) - cite it in reports ◉ COURSE: SAST vs DAST Answer: SAST analyzes source code without running it (Bandit, flake8); DAST probes the running application from outside (penetration testing)
◉ COURSE: CIA triad Answer: Confidentiality (only authorized access), Integrity (data unaltered), Availability (accessible when needed) - every vuln maps to breaking at least one ◉ COURSE: Least privilege Answer: Every user/process gets only the minimum access needed; in Task 2 the USERS_DB roles (admin/user/guest) exist to enforce it on endpoints ◉ COURSE: Defense in depth Answer: Multiple overlapping controls so one failure doesn't equal compromise, e.g. input validation + parameterized queries + least- privilege DB account ◉ COURSE: OWASP Top 10 Answer: The Open Worldwide Application Security Project's ranked list of the most critical web app risks (injection, broken access control, crypto failures, etc.) - the industry vocabulary for Task 2 vuln categories ◉ COURSE: CWE vs CVE Answer: CWE = category of weakness in code (CWE-259 hardcoded password); CVE = a specific disclosed vulnerability in a specific product
Answer: Severity maps to suspicion: equipment is a fixed dropdown so an unknown value implies a crafted request (ERROR); days is free text so typos are expected user error (WARNING) ◉ TASK 1: What does int(None) raise and when? Answer: TypeError, when the days field is missing from the POST entirely - that's why the WARNING handler catches (ValueError, TypeError), not ValueError alone ◉ TASK 1: Why does days raise ValueError when zero or negative inside the try? Answer: It funnels the business rule into the same handled WARNING path the report describes instead of a separate return branch ◉ TASK 1: The two assertions Answer: 1: validate_username asserts username is a non-empty string; 2: /login asserts request.remote_addr matches an IPv4 regex
validation; a failed assert during a request = 500, which is acceptable for assumption violations ◉ TASK 1: The 4 rubric-cited tests Answer: test_invalid_equipment_type_handled (KeyError path + ERROR log), test_non_numeric_days_handled (ValueError path + WARNING), test_negative_days_rejected (nonpositive days ValueError), test_student_input_validation (allowlist + assertion) - suite has 6 total, all must pass ◉ TASK 1: Why do hardcoded secret_key and password stay in Task 1? Answer: They are Bandit CWE-259 findings deliberately out of scope
◉ TASK 2: What does part C require of the tests? Answer: pytest naming conventions (test_*), assert statements validating expected outcomes, successful execution against the secured app, descriptive console comments explaining each outcome, and passing evidence for all 4 remediated vulns ◉ TASK 2: SQL injection - what and fix Answer: Attacker input alters the SQL query structure (the classic quote OR 1 equals 1 comment payload); fix with parameterized queries/prepared statements, never string concatenation, plus input validation as depth ◉ TASK 2: XSS - what and fix Answer: Attacker-supplied script executes in another user's browser (script tags in a form field); fix with output encoding/escaping (Jinja2 autoescape), input validation, and Content-Security-Policy ◉ TASK 2: Broken access control - what and fix Answer: An endpoint returns data or performs actions without verifying identity or role; fix by requiring authentication then enforcing role checks (least privilege) on every endpoint, not just the UI ◉ TASK 2: Missing rate limiting - what and fix
Answer: Unlimited requests enable brute force and DoS; fix by capping requests per key/IP per window (e.g. Flask-Limiter) and returning 429 Too Many Requests ◉ TASK 2: Hardcoded credentials - the Task 2 remediation Answer: Move secrets to environment variables or a config outside the repo (os.environ / python-dotenv), rotate the exposed values, and store password HASHES not plaintext ◉ TASK 2: Password hashing done right Answer: werkzeug.security generate_password_hash to store, check_password_hash to verify; salting = random per-password value so identical passwords hash differently, defeating rainbow tables; hash (one-way) not encrypt because the server never needs plaintext back ◉ TASK 2: API key vs OAuth Answer: API key = static shared secret identifying the caller, simple but no user identity or scopes; OAuth = token-based delegated authorization with scopes and expiry - the task expects you to explain how each protects APIs ◉ TASK 2: The encryption method for traffic (part D4)
◉ TOOLS: flake Answer: Python linter combining pyflakes/pycodestyle; in this course its report flags the general security issues (part A) like bare excepts and risky patterns, each as file:line:code ◉ TOOLS: pytest Answer: Test framework: files/functions named test_*, plain assert statements, run with python3 - m pytest; - k runs one test by name (how you capture B5 screenshots); exit green = rubric evidence ◉ TOOLS: Flask test_client Answer: Fake HTTP client that posts to routes in-process without a running server - how test_run.py exercises /login and /rent ◉ TOOLS: Python logging module Answer: logging.basicConfig(filename, format, level) once at module top configures the root logger for every route; levels DEBUG 10, INFO 20, WARNING 30, ERROR 40, CRITICAL 50 ◉ TOOLS: re module in this course Answer: Regex for the IPv4 assertion in /login (Task 1) and an input- validation technique you can cite in Task 2 (pattern-match before trusting input)
◉ TOOLS: venv + requirements.txt Answer: python3 - m venv venv, activate, pip install - r requirements.txt - isolated per-project dependencies so the graders' environment matches yours ◉ TOOLS: WGU similarity checker Answer: Runs automatically on upload; ALWAYS wait for the report and review it before clicking submit - academic authenticity gate ◉ TOOLS: Grammarly for Education Answer: Auto-assesses professional communication before evaluation; the submission cannot pass without this aspect passing, so review its feedback pre-submit ◉ DOCS: Bandit documentation Answer: bandit.readthedocs.io - each finding links to its plugin page (e.g. /plugins/b105_hardcoded_password_string.html); cite when justifying Task 2 remediations ◉ DOCS: CWE- 259 Answer: cwe.mitre.org/data/definitions/259.html - Use of Hard- coded Password; the CWE both tasks' credential findings map to ◉ DOCS: Python logging docs
Answer: Byrne, Full Stack Python Security: hashing/salting, TLS, attack chapters - the epub is in your D385 folder; report quotes must be verbatim + cited ◉ PRACTICE: The log shows ERROR with EVENT Invalid equipment type requested - what exactly happened in code? Answer: A POST to /rent had an equipment_type not in EQUIPMENT_PRICES, the dict lookup raised KeyError, the except KeyError block logged ERROR and returned safely - no crash ◉ PRACTICE: POST /rent with days set to abc - trace it Answer: int(abc) raises ValueError inside the try, the (ValueError, TypeError) handler logs WARNING with EVENT/ACTION, user gets a friendly error - expected-typo path, not suspicious ◉ PRACTICE: POST /rent with the days field missing entirely - trace it Answer: form.get returns None, int(None) raises TypeError, same WARNING handler catches it - the edge case that justifies catching TypeError alongside ValueError ◉ PRACTICE: Ops deploys with python - O. What breaks in your rubric evidence?
Answer: Both assertions vanish, so no assertion protection AND no INFO pass entries would be generated - proving assertions are assumption documentation, not security controls ◉ PRACTICE: Evaluator asks why a negative days value is only a WARNING and not an attack Answer: Days is free-text where typos/misunderstanding are the base rate; the value is rejected either way (ValueError raised and handled), so severity reflects likely intent, and the log still records it for pattern review ◉ PRACTICE: flake8 flags a bare except - remediate it Answer: Catch the specific exceptions the block can actually raise, log the failure at an appropriate level, and return a safe message; bare except hides real attacks and masks bugs - cite unsafe exception handling (part A category) ◉ PRACTICE: Bandit flags line 84 with a hardcoded DB password - full remediation Answer: Read the value from an environment variable (os.environ, python-dotenv for local dev), remove the literal, comment out the old line per task rules, rotate the exposed credential, screenshot before/after with line numbers
◉ PRACTICE: One IP sends 1,200 requests to /api/v1/login in 60 seconds - classify and mitigate Answer: Brute force / DoS pattern enabled by missing rate limiting; mitigate with per-IP/per-key request caps returning 429, account lockout/backoff, and alerting on the log pattern ◉ PRACTICE: Write a valid pytest test name proving your SQLi fix Answer: test_sql_injection_blocked (any test_* name works) - post a malicious payload via test_client, assert the response is safely rejected and no unauthorized data returns, with a descriptive comment printed for the console screenshot ◉ PRACTICE: Which encryption method secures application traffic here? (part D4) Answer: TLS (HTTPS) - asymmetric handshake to exchange keys, symmetric encryption for the session; protects credentials and API keys in transit; cite Byrne's TLS chapter ◉ PRACTICE: A finding scores CVSS 9.8 - what do you write for severity and why does it matter? Answer: CRITICAL (9.0 and up); severity drives remediation priority and is how the pen-test report justifies which two vulns you fixed first ◉