CS FundamentalsHardProduct-company placement · Security interview
A forum shows user comments, and an attacker posts a comment containing a script tag that runs in other users' browsers. Which is the primary fix?
- A. Mark the session cookie HttpOnly
- B. Encode untrusted data for the context where it is output (HTML-escape in page content), optionally backed by a Content-Security-Policy
- C. Switch the site from HTTP to HTTPS
- D. Use parameterised SQL queries when storing comments
Correct answer: B. Encode untrusted data for the context where it is output (HTML-escape in page content), optionally backed by a Content-Security-Policy
This is stored XSS: the fix is context-aware output encoding so the browser treats the text as data. HttpOnly only stops scripts reading the cookie, HTTPS does not affect injected script, and parameterised queries prevent SQL injection, not XSS.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- A popular product page is cached with a fixed 60-second TTL. Every minute, as the entry expires, thousands of requests miss at once and…
- According to the cone of uncertainty (Boehm, McConnell), at the initial-concept stage a project's eventual effort can differ from a…
- A team uses feature toggles. Which kind should normally be deleted soon after the feature is fully launched?
- A flight-control system uses N-version programming: three teams independently write the same module from one specification, and a voter…
- A team adds hundreds of snapshot tests that compare whole rendered pages with stored output. Six months later, which problem is most…
- A coverage-guided fuzzer runs a parser for hours with random mutations of seed inputs, and AddressSanitizer is enabled. What can it find…