Web Application Security Basics
- 22Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What are the three fundamental building blocks of web applications?
What are the three fundamental building blocks of web applications?
22 questions
- 1
What are the three fundamental building blocks of web applications?
- A
HTML, CSS, and JavaScript
- B
DOM, XML, and JSON
- C
HTTP, URL, and TCP
- D
Browser, Server, and Database
Correct answer
AHTML, CSS, and JavaScript
Explanation
Web applications are built using HTML for structure, CSS for styling, and JavaScript for dynamic behavior.
- A
- 2
What is a user agent in the context of web applications?
- A
The web server that hosts the application
- B
Any application that acts on behalf of the user, such as a browser
- C
A program that automatically fills forms for the user
- D
A security tool that monitors user activity
Correct answer
BAny application that acts on behalf of the user, such as a browser
Explanation
The user agent, typically a browser, speaks HTTP and acts on the user's behalf.
- A
- 3
What does the Document Object Model (DOM) provide?
- A
A programming interface for JavaScript to interact with an HTML document
- B
A protocol for transferring files between servers
- C
A security policy for cross-origin requests
- D
A styling mechanism for web pages
Correct answer
AA programming interface for JavaScript to interact with an HTML document
Explanation
The DOM is the interface that allows JavaScript to read, modify, and update the HTML document.
- A
- 4
What can client-side JavaScript do within a web application?
- A
Only display static text and images
- B
Access the user's entire file system
- C
Modify or read any data from the same web application
- D
Communicate with any server regardless of origin
Correct answer
CModify or read any data from the same web application
Explanation
JavaScript can manipulate the DOM and access data within the same web application, limited by the same-origin policy.
- A
- 5
What is the first line of an HTTP GET request?
- A
HTTP/1.1 GET /path
- B
HTTP/1.1 200 OK
- C
GET /path HTTP/1.1 followed by headers
- D
GET /path HTTP/1.1
Correct answer
CGET /path HTTP/1.1 followed by headers
Explanation
An HTTP GET request starts with the verb (GET), the path, and the HTTP version, followed by headers. The exact line is 'GET /path HTTP/1.1'.
- A
- 6
What does the Referer header in an HTTP request indicate?
- A
The preferred language of the user
- B
The type of browser the user is using
- C
The URL of the page that linked or referred the user to the current page
- D
The IP address of the user's computer
Correct answer
CThe URL of the page that linked or referred the user to the current page
Explanation
The Referer header tells the web server which site the user came from, which can be used for analytics or security checks.
- A
- 7
What does the HTTP status code 200 indicate?
- A
The server encountered an error
- B
The request is unauthorized
- C
The page was not found
- D
The request was successful
Correct answer
DThe request was successful
Explanation
Status code 200 means 'OK', indicating the server successfully processed the request.
- A
- 8
What is the purpose of the Content-Type HTTP response header?
- A
It specifies the cookies to be set
- B
It controls caching behavior
- C
It indicates the server's software version
- D
It tells the browser how to interpret the response body
Correct answer
DIt tells the browser how to interpret the response body
Explanation
Content-Type tells the browser whether the body is HTML, JavaScript, an image, etc., so it can process it correctly.
- A
- 9
What is the same-origin policy (SOP)?
- A
A rule that requires all web pages to share the same domain name
- B
A security mechanism that prevents JavaScript from one origin from accessing resources from a different origin
- C
A standard that forces all websites to use HTTPS
- D
A policy that allows unrestricted cross-origin requests
Correct answer
BA security mechanism that prevents JavaScript from one origin from accessing resources from a different origin
Explanation
The same-origin policy restricts how a document or script loaded from one origin can interact with resources from another origin.
- A
- 10
What three components define an origin?
- A
Hostname, port, and query string
- B
Protocol, domain name, and path
- C
Protocol (scheme), hostname, and port
- D
Scheme, domain, and subdomain
Correct answer
CProtocol (scheme), hostname, and port
Explanation
An origin is defined by the combination of scheme (e.g., http, https), hostname (e.g., example.com), and port (e.g., 80, 443).
- A
- 11
Are and considered the same origin?
- A
No, because they have different hostnames
- B
Yes, because the port is the same (default)
- C
No, because they have different protocols (HTTP vs HTTPS)
- D
Yes, because the hostname is the same
Correct answer
CNo, because they have different protocols (HTTP vs HTTPS)
Explanation
The protocol is part of the origin definition, so HTTP and HTTPS are different origins even if the hostname is identical.
- A
- 12
What does the X-Frame-Options HTTP response header do?
- A
It specifies the frame size for the page
- B
It allows the page to be loaded in an iframe from any origin
- C
It prevents a page from being displayed in an iframe by another page
- D
It encrypts the page content during transport
Correct answer
CIt prevents a page from being displayed in an iframe by another page
Explanation
X-Frame-Options is a mitigation against clickjacking by controlling whether the page can be embedded in an iframe.
- A
- 13
What is clickjacking?
- A
A method to steal cookies by intercepting clicks
- B
A way to capture keystrokes by overlaying fake buttons
- C
An attack that injects malicious JavaScript into a page
- D
A technique that tricks users into clicking something different from what they perceive, by layering iframes
Correct answer
DA technique that tricks users into clicking something different from what they perceive, by layering iframes
Explanation
Clickjacking uses invisible iframes overlaid on visible elements to trick users into clicking unintended elements, like a checkout button.
- A
- 14
What does the same-site concept refer to?
- A
Pages that use the same protocol and port
- B
The entire domain including all subdomains without restriction
- C
The top-level domain plus one additional subdomain (e.g., emabracethered.com and blog.embracethered.com)
- D
Any web page that shares the same IP address
Correct answer
CThe top-level domain plus one additional subdomain (e.g., emabracethered.com and blog.embracethered.com)
Explanation
Same-site is broader than same-origin; it includes all subdomains of a registered domain, e.g., embracethered.com and blog.embracethered.com are same-site.
- A
- 15
Why are cookies used in HTTP?
- A
To store user passwords on the client side
- B
To encrypt data transmitted between browser and server
- C
To create state and maintain sessions across multiple requests, since HTTP is stateless
- D
To improve page loading speeds by caching content
Correct answer
CTo create state and maintain sessions across multiple requests, since HTTP is stateless
Explanation
HTTP is a stateless protocol; cookies allow servers to remember user state (e.g., login sessions) by storing small pieces of data in the browser.
- A
- 16
How does a browser send cookies to a server?
- A
Only for POST requests
- B
Only if the cookie has the Secure flag set
- C
Only when JavaScript explicitly sends them
- D
Automatically, with every HTTP request to a domain for which the browser has stored cookies
Correct answer
DAutomatically, with every HTTP request to a domain for which the browser has stored cookies
Explanation
Browsers automatically include cookies in requests to the matching domain, without requiring any code action.
- A
- 17
What does the HttpOnly flag on a cookie do?
- A
It makes the cookie expire immediately after being set
- B
It ensures the cookie is only sent over HTTPS
- C
It prevents client-side scripts (like JavaScript) from accessing the cookie
- D
It stops the cookie from being sent cross-site
Correct answer
CIt prevents client-side scripts (like JavaScript) from accessing the cookie
Explanation
The HttpOnly flag makes the cookie inaccessible to JavaScript, reducing the risk of cookie theft via XSS.
- A
- 18
What does the Secure flag on a cookie enforce?
- A
The cookie is encrypted on the client side
- B
The cookie is not accessible via JavaScript
- C
The cookie is only transmitted over encrypted HTTPS connections
- D
The cookie can only be read by the server
Correct answer
CThe cookie is only transmitted over encrypted HTTPS connections
Explanation
The Secure flag ensures the cookie is not sent over unencrypted HTTP, protecting it from network sniffing.
- A
- 19
What is the purpose of the SameSite cookie attribute?
- A
It forces the cookie to be sent only for subdomain requests
- B
It encrypts the cookie value
- C
It ensures the cookie is only set for the exact same origin
- D
It controls whether the cookie is sent in cross-site requests, helping to prevent CSRF and tracking
Correct answer
DIt controls whether the cookie is sent in cross-site requests, helping to prevent CSRF and tracking
Explanation
The SameSite attribute restricts cookie sending to same-site requests, which mitigates cross-site request forgery (CSRF) and limits ad tracking.
- A
- 20
What is Strict-Transport-Security (HSTS) used for?
- A
It enables HTTP/2 protocol for faster loading
- B
It instructs the browser to always use HTTPS for future requests to that domain
- C
It prevents cookies from being sent over HTTP
- D
It forces the use of a specific TLS certificate
Correct answer
BIt instructs the browser to always use HTTPS for future requests to that domain
Explanation
HSTS tells the browser to automatically upgrade any HTTP requests to HTTPS, preventing downgrade attacks.
- A
- 21
Which organization provides free TLS certificates?
- A
Symantec
- B
Cloudflare
- C
Let's Encrypt
- D
Verizon
Correct answer
CLet's Encrypt
Explanation
Let's Encrypt is a free, automated, and open certificate authority that offers TLS certificates.
- A
- 22
Which tool was specifically mentioned for inspecting HTTP traffic on Windows?
- A
Wireshark
- B
Nmap
- C
Fiddler
- D
Metasploit
Correct answer
CFiddler
Explanation
Fiddler is a free HTTP debugging proxy that can inspect requests and responses, and was highlighted for use on Windows.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.