1What is the main purpose of authentication in a web application?
Authentication Concepts
Easy
A.To improve network speed
B.To format a web page
C.To verify a user's identity
D.To compress database files
Correct Answer: To verify a user's identity
Explanation:
Authentication confirms that a user is who they claim to be.
Incorrect! Try again.
2Which credential is commonly used with a username during authentication?
Authentication Concepts
Easy
A.A password
B.A table name
C.A URL path
D.A stylesheet
Correct Answer: A password
Explanation:
A username and password are commonly used together to authenticate a user.
Incorrect! Try again.
3What does a session commonly store after a user logs in?
Session Management
Easy
A.The server's source code
B.The user's login state
C.The website's font files
D.The database schema
Correct Answer: The user's login state
Explanation:
A session helps the application remember that the user has already logged in.
Incorrect! Try again.
4What usually happens to a user's session when they log out?
Session Management
Easy
A.It is destroyed or invalidated
B.It installs a new browser
C.It changes the page layout
D.It becomes a database table
Correct Answer: It is destroyed or invalidated
Explanation:
Logging out normally ends or invalidates the active session.
Incorrect! Try again.
5What is a protected route?
Protected Routes
Easy
A.A route used only for images
B.A route with no server logic
C.A route that creates CSS files
D.A route limited to authorized users
Correct Answer: A route limited to authorized users
Explanation:
A protected route checks access before allowing a user to view or use it.
Incorrect! Try again.
6Where is an unauthenticated user commonly sent when opening a protected route?
Protected Routes
Easy
A.To the CSS editor
B.To the server terminal
C.To the login page
D.To the database console
Correct Answer: To the login page
Explanation:
Applications commonly redirect unauthenticated users to a login page.
Incorrect! Try again.
7What does authorization determine?
Authorization
Easy
A.Whether a server is powered on
B.What an authenticated user may do
C.Which browser is installed
D.How a password is typed
Correct Answer: What an authenticated user may do
Explanation:
Authorization decides which resources and actions a user is permitted to access.
Incorrect! Try again.
8Which check is an example of authorization?
Authorization
Easy
A.Checking whether HTML is valid
B.Checking whether Wi-Fi is active
C.Checking whether a password matches
D.Checking permission to delete a post
Correct Answer: Checking permission to delete a post
Explanation:
Authorization checks whether a user has permission to perform a specific action.
Incorrect! Try again.
9In role-based access control, permissions are primarily assigned to what?
Role-based Access Control
Easy
A.Roles
B.Queries
C.Images
D.Browsers
Correct Answer: Roles
Explanation:
RBAC assigns permissions to roles, which are then assigned to users.
Incorrect! Try again.
10Which role would commonly have permission to manage all user accounts?
Role-based Access Control
Easy
A.Administrator
B.Subscriber
C.Viewer
D.Guest
Correct Answer: Administrator
Explanation:
An administrator role commonly has broad permissions, including user management.
Incorrect! Try again.
11What does ORM stand for?
ORM Basics
Easy
A.Object Request Method
B.Online Resource Management
C.Open Routing Model
D.Object-Relational Mapping
Correct Answer: Object-Relational Mapping
Explanation:
ORM stands for Object-Relational Mapping.
Incorrect! Try again.
12What does an ORM help developers do?
ORM Basics
Easy
A.Design icons as vector images
B.Work with database data as objects
C.Compile styles into web pages
D.Configure physical network cables
Correct Answer: Work with database data as objects
Explanation:
An ORM maps database records to objects used by application code.
Incorrect! Try again.
13What is required for an application to connect to a database?
Database Connectivity
Easy
A.A database connection string
B.A screen resolution value
C.A page animation setting
D.A browser bookmark file
Correct Answer: A database connection string
Explanation:
A connection string provides details the application needs to reach the database.
Incorrect! Try again.
14Which value is commonly included in database connection settings?
Database Connectivity
Easy
A.Font family
B.Database host
C.Button color
D.Image width
Correct Answer: Database host
Explanation:
The database host identifies the server where the database is running.
Incorrect! Try again.
15What does the letter C represent in CRUD?
CRUD Operations
Easy
A.Calculate
B.Create
C.Connect
D.Compile
Correct Answer: Create
Explanation:
In CRUD, C stands for Create, which means adding new data.
Incorrect! Try again.
16Which CRUD operation changes an existing database record?
CRUD Operations
Easy
A.Create
B.Read
C.Delete
D.Update
Correct Answer: Update
Explanation:
The Update operation modifies data that already exists.
Incorrect! Try again.
17Which CRUD operation retrieves stored data?
CRUD Operations
Easy
A.Read
B.Delete
C.Update
D.Create
Correct Answer: Read
Explanation:
The Read operation retrieves existing data from a database.
Incorrect! Try again.
18Why is user input validated before it is stored?
Data Validation
Easy
A.To increase the monitor brightness
B.To rename the application server
C.To ensure it meets expected rules
D.To change the browser theme
Correct Answer: To ensure it meets expected rules
Explanation:
Validation checks that input has the required type, format, and constraints.
Incorrect! Try again.
19Which is a basic validation rule for a required email field?
Data Validation
Easy
A.It must not be empty
B.It must create a session
C.It must delete a record
D.It must contain an image
Correct Answer: It must not be empty
Explanation:
A required field must contain a value before the form can be accepted.
Incorrect! Try again.
20Why are environment variables commonly used in web applications?
Environment Variables
Easy
A.To arrange records in database rows
B.To store configuration outside source code
C.To define headings in a web page
D.To draw interface icons in HTML
Correct Answer: To store configuration outside source code
Explanation:
Environment variables keep settings such as database URLs and secret keys outside the source code.
Incorrect! Try again.
21A web application stores user passwords for login verification. Which approach provides the best protection if the database is exposed?
Authentication Concepts
Medium
A.Store passwords using a shared application secret
B.Store passwords as salted cryptographic hashes
C.Store passwords as plain text with restricted access
D.Store passwords using reversible encryption
Correct Answer: Store passwords as salted cryptographic hashes
Explanation:
Salted hashing is one-way and makes precomputed password attacks more difficult. Passwords should not be stored in plain text or reversible form.
Incorrect! Try again.
22Why should a server regenerate a session identifier after a user successfully logs in?
Authentication Concepts
Medium
A.To make database queries execute faster
B.To allow multiple passwords for one account
C.To prevent session fixation attacks
D.To reduce the size of the session cookie
Correct Answer: To prevent session fixation attacks
Explanation:
Regenerating the session identifier prevents an attacker from forcing a known session ID on a user and later reusing it after authentication.
Incorrect! Try again.
23A session cookie should not be accessible through client-side JavaScript because of which cookie attribute?
Session Management
Medium
A.SameSite
B.Secure
C.Max-Age
D.HttpOnly
Correct Answer: HttpOnly
Explanation:
The HttpOnly attribute prevents JavaScript from reading the cookie, reducing the impact of many cross-site scripting attacks.
Incorrect! Try again.
24An application must ensure that a session cookie is sent only over HTTPS connections. Which cookie setting addresses this requirement?
Session Management
Medium
A.HttpOnly
B.SameSite
C.Path
D.Secure
Correct Answer: Secure
Explanation:
The Secure attribute instructs the browser to send the cookie only over HTTPS connections.
Incorrect! Try again.
25What is the primary purpose of an idle session timeout?
Session Management
Medium
A.To increase the number of concurrent sessions
B.To encrypt data stored in the database
C.To invalidate inactive sessions after a period
D.To prevent users from changing passwords
Correct Answer: To invalidate inactive sessions after a period
Explanation:
An idle timeout reduces the risk of unauthorized access when a user leaves an authenticated session unused.
Incorrect! Try again.
26A request to /dashboard is received without a valid authenticated session. What should protected-route middleware typically do?
Protected Routes
Medium
A.Redirect or return an authentication error
B.Create a temporary administrator session
C.Render the dashboard with empty data
D.Ignore the request and continue processing
Correct Answer: Redirect or return an authentication error
Explanation:
Protected-route middleware must stop unauthenticated requests and either redirect the user to login or return an appropriate 401 Unauthorized response.
Incorrect! Try again.
27A frontend hides an administrator link, but the corresponding API endpoint has no server-side authentication check. What is the main security problem?
Protected Routes
Medium
A.The database schema becomes inconsistent
B.The API can still be called directly
C.The page may load more slowly
D.The browser cannot cache the link
Correct Answer: The API can still be called directly
Explanation:
Hiding a user-interface element does not protect an endpoint. Authorization checks must be enforced on the server for every sensitive request.
Incorrect! Try again.
28A logged-in user requests another user's private profile by changing the user ID in the URL. Which authorization check is needed?
Authorization
Medium
A.Check whether the requester owns the resource
B.Check whether the browser supports cookies
C.Check whether the request uses HTTPS
D.Check whether the URL contains a numeric ID
Correct Answer: Check whether the requester owns the resource
Explanation:
Authentication confirms who the requester is, while authorization must determine whether that user may access the specific profile.
Incorrect! Try again.
29Which response status is most appropriate when a user is authenticated but lacks permission to delete a resource?
Authorization
Medium
A.403 Forbidden
B.500 Internal Server Error
C.302 Found
D.200 OK
Correct Answer: 403 Forbidden
Explanation:
403 Forbidden indicates that the server understood the request but refuses to authorize the authenticated user to perform it.
Incorrect! Try again.
30In a role-based access control system, a user has the role editor, which permits updating articles but not deleting them. What should happen when the user sends a delete request?
Role-based Access Control
Medium
A.The request should be authorized automatically
B.The request should be denied by a permission check
C.The request should be converted into a read request
D.The request should create a new editor role
Correct Answer: The request should be denied by a permission check
Explanation:
RBAC maps roles to permissions. Since editor lacks the delete permission, the server should reject the delete operation.
Incorrect! Try again.
31What is a key advantage of assigning permissions to roles instead of configuring permissions separately for every user?
Role-based Access Control
Medium
A.It allows users to bypass server checks
B.It simplifies consistent permission management
C.It guarantees that roles cannot be changed
D.It removes the need for authentication
Correct Answer: It simplifies consistent permission management
Explanation:
Roles centralize permission rules, making access policies easier to apply, review, and update across many users.
Incorrect! Try again.
32In an ORM, a User class is mapped to a database table. What does an instance of the class usually represent?
ORM Basics
Medium
A.A row in the mapped table
B.A database server process
C.A database connection pool
D.A collection of unrelated schemas
Correct Answer: A row in the mapped table
Explanation:
ORMs commonly represent table rows as objects, with object properties corresponding to columns.
Incorrect! Try again.
33What is the main purpose of an ORM migration?
ORM Basics
Medium
A.To disable database transactions
B.To replace all application routes
C.To hash every user password again
D.To change the database schema in a tracked way
Correct Answer: To change the database schema in a tracked way
Explanation:
Migrations record and apply schema changes such as creating tables, adding columns, or modifying indexes in a repeatable manner.
Incorrect! Try again.
34An application is deployed to production and fails because it cannot connect to the database. Which configuration should be checked first?
Database Connectivity
Medium
A.The CSS framework version
B.The database connection string and credentials
C.The browser's font settings
D.The HTML document title
Correct Answer: The database connection string and credentials
Explanation:
Connection failures commonly result from an incorrect host, port, database name, username, password, or network setting.
Incorrect! Try again.
35Why should a web application use a connection pool for frequent database access?
Database Connectivity
Medium
A.It converts relational tables into JSON files
B.It guarantees that every query is valid
C.It reuses connections and reduces setup overhead
D.It removes the need for database indexes
Correct Answer: It reuses connections and reduces setup overhead
Explanation:
Connection pools maintain reusable database connections, improving performance and limiting the overhead of repeatedly opening new connections.
Incorrect! Try again.
36Which operation best represents updating a user's email address in a database?
CRUD Operations
Medium
A.Updating an existing record
B.Creating a new table
C.Reading a database schema
D.Deleting the user record
Correct Answer: Updating an existing record
Explanation:
Changing a value in an existing user's record is an update operation, corresponding to the update part of CRUD.
Incorrect! Try again.
37A user submits a form to create a new blog post. Which practice best reduces SQL injection risk when inserting the data?
CRUD Operations
Medium
A.Remove spaces from the submitted text
B.Concatenate form values into SQL text
C.Use parameterized queries or ORM binding
D.Convert all values to uppercase
Correct Answer: Use parameterized queries or ORM binding
Explanation:
Parameterized queries and ORM binding keep user input separate from executable SQL syntax, reducing SQL injection risk.
Incorrect! Try again.
38A registration endpoint receives an email field that contains an empty string. What is the best validation behavior?
Data Validation
Medium
A.Reject it with a clear validation error
B.Store it as a random generated value
C.Convert it to an administrator address
D.Accept it and let the database decide
Correct Answer: Reject it with a clear validation error
Explanation:
Required fields should be validated before processing. Returning a clear error helps the client correct invalid input and protects data quality.
Incorrect! Try again.
39Why should validation be performed on the server even when the frontend already validates the form?
Correct Answer: Clients can bypass or modify frontend checks
Explanation:
Frontend validation improves user experience, but the server must enforce rules because clients are not trusted and can send arbitrary requests.
Incorrect! Try again.
40Which value is most appropriate to store in an environment variable rather than directly in source code?
Environment Variables
Medium
A.A static application logo path
B.A database password
C.A public page heading
D.A fixed CSS class name
Correct Answer: A database password
Explanation:
Environment variables keep deployment-specific and sensitive configuration, such as database passwords, outside the source code repository.
Incorrect! Try again.
41A web application stores passwords using a fast hash function with a unique salt per user. An attacker obtains the password table and can evaluate billions of hashes per second. Which change most directly improves resistance to offline cracking?
Authentication Concepts
Hard
A.Replace the hash with a keyed HMAC
B.Use a memory-hard password hashing function
C.Encrypt the password table with the application key
D.Use a longer session expiration period
Correct Answer: Use a memory-hard password hashing function
Explanation:
Memory-hard functions such as Argon2id make large-scale guessing expensive in both computation and memory, which is specifically effective against offline password cracking.
Incorrect! Try again.
42A login endpoint returns the same HTTP status, response body structure, and approximate timing for an unknown email and an incorrect password. What security property is this design primarily intended to provide?
Authentication Concepts
Hard
A.Forward secrecy for credentials
B.Protection against session fixation
C.Resistance to account enumeration
D.Prevention of CSRF token reuse
Correct Answer: Resistance to account enumeration
Explanation:
Uniform responses and timing reduce the ability of attackers to determine whether an account exists based on login behavior.
Incorrect! Try again.
43A user logs in successfully, but the server keeps the anonymous session identifier and merely adds an authenticated flag. Which remediation is most important?
Session Management
Hard
A.Increase the session cookie's maximum age
B.Store the session identifier in localStorage
C.Allow the identifier on cross-site requests
D.Rotate the session identifier after authentication
Correct Answer: Rotate the session identifier after authentication
Explanation:
Rotating the identifier after privilege elevation prevents session fixation, where an attacker preselects or obtains a session ID that the victim later authenticates.
Incorrect! Try again.
44A server-side session store uses a sliding idle timeout. Two requests from the same session arrive concurrently: one is valid at time , while the other was sent before the session expired but reaches the server afterward. Which design best prevents stale-request resurrection?
Session Management
Hard
A.Extend expiration whenever the session ID is syntactically valid
B.Use atomic compare-and-update expiration checks
C.Trust the timestamp embedded in the browser cookie
D.Refresh the expiry timestamp in every request handler
Correct Answer: Use atomic compare-and-update expiration checks
Explanation:
Atomic validation and update operations prevent concurrent requests from extending an already expired session because of race conditions.
Incorrect! Try again.
45A single-page application hides an admin link for non-admin users, but its API endpoint only checks whether a request has a valid login session. What is the primary flaw?
Protected Routes
Hard
A.The login page should be rendered server-side
B.The browser should hash the user's role
C.The interface should use shorter access tokens
D.The API trusts presentation logic for authorization
Correct Answer: The API trusts presentation logic for authorization
Explanation:
Client-side route hiding is not a security boundary. The API must independently authenticate the request and authorize the requested operation.
Incorrect! Try again.
46A protected route checks authentication in middleware, then redirects unauthenticated users to a login page. An attacker supplies a URL containing an external destination as the return parameter. Which control is required?
Protected Routes
Hard
A.Store the destination in a query string
B.Permit any HTTPS destination after login
C.Encrypt the destination with a public key
D.Permit only relative internal return paths
Correct Answer: Permit only relative internal return paths
Explanation:
Allowing arbitrary destinations can create an open redirect. The return target should be validated as a safe internal path or selected from an allowlist.
Incorrect! Try again.
47An endpoint permits a user to fetch /orders/4821 after checking that the user is logged in, but it does not compare the order's owner ID with the requester. What vulnerability remains?
Authorization
Hard
A.Cross-site request forgery
B.Session fixation
C.Credential stuffing
D.Broken object-level authorization
Correct Answer: Broken object-level authorization
Explanation:
Authentication establishes who the requester is, but object-level authorization must establish whether that requester may access order 4821.
Incorrect! Try again.
48A document update service first verifies that a user may edit a document and then performs the update using only the document ID. The document can be moved between tenants by another process between these operations. Which solution best addresses the issue?
Authorization
Hard
A.Expose the tenant ID as a client-editable field
B.Cache the authorization result for five minutes
C.Perform authorization and mutation in one transaction
D.Check authorization only after the update commits
Correct Answer: Perform authorization and mutation in one transaction
Explanation:
Combining the authorization predicate with the mutation in an appropriate transaction prevents time-of-check-to-time-of-use races.
Incorrect! Try again.
49A user has both viewer and editor roles. The application denies access if any assigned role lacks permission, even when another role grants it. Which RBAC evaluation model is usually intended instead?
Role-based Access Control
Hard
A.Deny if the role list contains a wildcard
B.Grant if at least one applicable role permits
C.Ignore roles and use the user's creation date
D.Grant only when every role permits
Correct Answer: Grant if at least one applicable role permits
Explanation:
Common additive RBAC evaluates permissions as the union of applicable role grants, while explicit deny rules, if supported, must be defined separately.
Incorrect! Try again.
50An administrator changes a user's role from admin to support, but existing access tokens contain the old role claim and remain valid for one hour. Which mitigation most directly limits stale privilege?
Role-based Access Control
Hard
A.Validate revocation or privilege version server-side
B.Increase the token lifetime for usability
C.Hide administrative controls after rendering
D.Move the role claim into a browser cookie
Correct Answer: Validate revocation or privilege version server-side
Explanation:
Server-side revocation checks or a privilege-version comparison can invalidate tokens issued before the role change instead of trusting stale embedded claims.
Incorrect! Try again.
51An ORM loads 1,000 posts and lazily fetches each author's record while rendering them. The database receives one query for posts and 1,000 author queries. What is the most appropriate correction when all authors are needed?
ORM Basics
Hard
A.Serialize each author into the post table
B.Increase the connection pool indefinitely
C.Use eager loading or a batched relation query
D.Disable all database indexes
Correct Answer: Use eager loading or a batched relation query
Explanation:
Eager loading or batching reduces the N+1 query pattern by retrieving related authors in a small number of queries.
Incorrect! Try again.
52An ORM model accepts a request body containing email, displayName, and isAdmin, and uses a generic update method. A client changes isAdmin despite lacking permission. Which ORM-level control is most relevant?
ORM Basics
Hard
A.Use lazy loading for all relationships
B.Apply an allowlist for mass-assigned fields
C.Enable automatic schema migration
D.Convert every column to a string
Correct Answer: Apply an allowlist for mass-assigned fields
Explanation:
Mass-assignment protection ensures that only explicitly permitted attributes, such as email and displayName, can be updated from client input.
Incorrect! Try again.
53A production service opens a new database connection for every request and occasionally exhausts the database connection limit under load. Which architecture is most appropriate?
Database Connectivity
Hard
A.Create one unmanaged connection per query
B.Share one connection globally across all requests
C.Use a bounded connection pool with release handling
D.Retry indefinitely without limiting concurrency
Correct Answer: Use a bounded connection pool with release handling
Explanation:
A bounded pool reuses connections while limiting concurrent database usage. Connections must be released even when requests fail.
Incorrect! Try again.
54A database transaction updates an inventory row, but a second transaction can read the intermediate value before the first transaction commits. Which database property is missing or inadequately configured?
Database Connectivity
Hard
A.Durability
B.Consistency
C.Atomicity
D.Isolation
Correct Answer: Isolation
Explanation:
Isolation controls how visible one transaction's intermediate changes are to concurrent transactions. Dirty reads indicate insufficient isolation.
Incorrect! Try again.
55An API implements PUT /users/7 by updating only fields present in the request and leaving all other fields unchanged. A client omits a field expecting it to be cleared. Which design correction is most accurate?
CRUD Operations
Hard
A.Use PUT only for deleting the resource
B.Replace the database with a document store
C.Treat every omitted field as an authorization failure
D.Document the endpoint as partial update semantics
Correct Answer: Document the endpoint as partial update semantics
Explanation:
Updating only supplied fields is PATCH-like behavior. The API should use or document partial-update semantics, while full replacement should define omitted fields explicitly.
Incorrect! Try again.
56Two clients read a product with version 12. Both submit updates, and the second update silently overwrites the first. Which implementation provides optimistic concurrency control?
CRUD Operations
Hard
A.Permit updates only from administrators
B.Add a random delay before every update
C.Read the product again after committing
D.Update only where the ID and version both match
Correct Answer: Update only where the ID and version both match
Explanation:
An update such as WHERE id = ? AND version = 12 detects a stale client when no row is affected; the successful update then increments the version.
Incorrect! Try again.
57A registration validator checks that an email has a valid format, but the database later rejects it because the email column is unique. Which validation strategy is correct?
Data Validation
Hard
A.Remove the constraint after validating the format
B.Rely only on a client-side uniqueness check
C.Keep the unique constraint and handle conflicts
D.Check uniqueness once during application startup
Correct Answer: Keep the unique constraint and handle conflicts
Explanation:
Application checks are vulnerable to races. The database constraint is authoritative, and the API should translate a uniqueness violation into a suitable response.
Incorrect! Try again.
58A server validates a request's JSON structure but accepts a string such as "999999999999999999999" for an integer amount, allowing inconsistent coercion across services. What is the strongest fix?
Data Validation
Hard
A.Convert every numeric value to floating point
B.Use strict schemas with bounded numeric constraints
C.Accept all strings and normalize them in the UI
D.Validate only after writing the value
Correct Answer: Use strict schemas with bounded numeric constraints
Explanation:
Strict schema validation should reject incorrect types and enforce safe ranges before business logic or persistence, avoiding inconsistent coercion and overflow.
Incorrect! Try again.
59A deployment reads DATABASE_URL successfully, but a secret containing a dollar sign and spaces is truncated or altered by the shell. Which practice best prevents this configuration error?
Environment Variables
Hard
A.Base64-encode every value without decoding it
B.Quote values according to the deployment environment
C.Expose the secret through a client-side configuration file
D.Embed the secret directly in source code
Correct Answer: Quote values according to the deployment environment
Explanation:
Shells and deployment tools interpret spaces, dollar signs, and other characters specially. Correct quoting or secret-manager injection preserves the exact value.
Incorrect! Try again.
60An application falls back to a development signing key when AUTH_SECRET is missing. In production, a deployment typo therefore starts successfully but issues forgeable tokens. Which design is safest?
Environment Variables
Hard
A.Fail startup when required secrets are absent
B.Use a predictable default key for availability
C.Log the missing key and continue normally
D.Generate a new key on every incoming request
Correct Answer: Fail startup when required secrets are absent
Explanation:
Required security-critical configuration should be validated at startup. Failing closed prevents the service from operating with a known or weak default secret.
Incorrect! Try again.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill.
The rest comes out of a student's own pocket: the domain, the storage,
and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it.
What it pays for →