Exam CAS-005 Topic 2 Question 127 Discussion

Actual exam question for CompTIA's CAS-005 exam
Question #: 127
Topic #: 2
During a forensic review of a cybersecurity incident, a security engineer collected a portion of the payload used by an attacker on a comprised web server Given the following portion of the code:

Which of the following best describes this incident?

Suggested Answer: C Vote an answer

The provided code snippet shows a script that captures the user's cookies and sends them to a remote server. This type of attack is characteristic of Cross-Site Scripting (XSS), specifically stored XSS, where the malicious script is stored on the target server (e.g., in a database) and executed in the context of users who visit the infected web page.
A . XSRF (Cross-Site Request Forgery) attack: This involves tricking the user into performing actions on a different site without their knowledge but does not involve stealing cookies via script injection.
B . Command injection: This involves executing arbitrary commands on the host operating system, which is not relevant to the given JavaScript code.
C . Stored XSS: The provided code snippet matches the pattern of a stored XSS attack, where the script is injected into a web page, and when users visit the page, the script executes and sends the user's cookies to the attacker's server.
D . SQL injection: This involves injecting malicious SQL queries into the database and is unrelated to the given JavaScript code.
Reference:
CompTIA Security+ Study Guide
OWASP (Open Web Application Security Project) guidelines on XSS
"The Web Application Hacker's Handbook" by Dafydd Stuttard and Marcus Pinto

by Sandy at Oct 14, 2026, 11:27 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

Contact Us

If you have any question please leave me your email address, we will reply and send email to you in 12 hours.

Our Working Time: ( GMT 0:00-15:00 ) From Monday to Saturday

Support: Contact now 

日本語 Deutsch 繁体中文 한국어