ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 324 - PT0-002 discussion

Report
Export

During a code review assessment, a penetration tester finds the following vulnerable code inside one of the web application files:

<% String id = request.getParameter('id'); %>

Employee ID: <%= id %>

Which of the following is the best remediation to prevent a vulnerability from being exploited, based on this code?

A.
Parameterized queries
Answers
A.
Parameterized queries
B.
Patch application
Answers
B.
Patch application
C.
Output encoding
Answers
C.
Output encoding
Suggested answer: C

Explanation:

Output encoding is a technique that prevents cross-site scripting (XSS) attacks by encoding the user input before displaying it on the web page. This way, any malicious scripts or HTML tags are rendered harmless and cannot execute on the browser. Output encoding is recommended by the OWASP Top 10 as a defense against XSS1. In this case, the vulnerable code is using a scriptlet to display the employee ID without any validation or encoding, which could allow an attacker to inject malicious code through the id parameter. Output encoding would prevent this by escaping any special characters in the id parameter.

Reference: The Official CompTIA PenTest+ Student Guide (Exam PT0-002) eBook, Chapter 4, Section 4.2.1: Cross-site Scripting; Best PenTest+ certification study resources and training materials, Section 1: Cross-site Scripting (XSS) Attack; OWASP Top 10 2021, A7: Cross-site Scripting (XSS).

asked 02/10/2024
Bonnie Lau
36 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first