01. A building management firm's ASP.NET Core Web API serves JSON to its mobile app. The team points an automated vulnerability scanner at the staging API with a bearer token configured, and the scan log shows the token accepted on every request. The report covers three URLs, the root and two health endpoints, although the controllers define more than sixty actions.
Which change to the scan setup lets it test those actions?
a) Increase the scanner's crawl depth and the number of pages it may visit
b) Record a sign-in sequence so the scanner re-authenticates when its token expires
c) Import the API's OpenAPI definition into the scanner
d) Enable the scanner's browser-based crawler for script-built pages
02. A fleet management vendor's ASP.NET Core API checks bearer tokens with a small in-house routine. The routine reads the token header, runs HMAC or RSA verification to match the algorithm the header declares, and uses the identity provider's published public key as the key in either case. The provider signs every genuine token with RSA. A penetration tester computed an HMAC over a hand-built token using that public key as the secret, and the API accepted it with a dispatcher-admin role.
Which change stops this forgery?
a) Validate the audience and lifetime claims of every token before the API reads its roles
b) Accept only the RSA algorithm the provider signs with and only its published keys
c) Require the provider to sign with a longer RSA key
d) Validate that the issuer claim names the identity provider's published issuer identifier
03. A nonprofit donor portal runs its ASP.NET Core app on four servers. Data Protection persists its keys with PersistKeysToFileSystem to a shared network folder and uses SetApplicationName, so authentication cookies and protected donor reference tokens work on every server. During a penetration test, a tester with read access to a file-server backup copied the key files and then built a valid authentication cookie offline.
What should the developer change?
a) Shorten the key lifetime with SetDefaultKeyLifetime on every server
b) Encrypt the keys at rest with ProtectKeysWithCertificate
c) Isolate cookies and tokens with distinct CreateProtector purpose strings
d) Move the key ring to a shared Azure Blob container under the same application name
04. A pharmacy chain's ASP.NET Core supplier portal lets each supplier enter the URL where its product sheet is published, and a background job downloads the sheet with HttpClient. Before downloading, the job rejects any URL whose text contains localhost or 127.0.0.1. A tester entered a URL on a domain the tester controls, and the chain's internal stock service logged a request from the portal moments later.
Which change to the job prevents this?
a) Add the private address ranges and the stock server's name to the deny list
b) Allow only https URLs on approved supplier hosts and refuse any whose resolved address is internal
c) Parse the URL with Uri.TryCreate and accept it only when it is absolute
d) Download each sheet with a short timeout and without default credentials
05. A school district portal built with ASP.NET Core signs staff in through an external OpenID Connect provider using the authorization code flow. To serve several school sites from one registration, the portal's client entry at the provider accepts any HTTPS redirect URL under the district's domain. An old school-site subdomain was later pointed at a hosting account that an attacker now controls, and sign-in responses for several staff accounts were delivered there.
Which change prevents this?
a) Register each school site's exact callback URL with the provider and remove the domain-wide pattern
b) Validate the state and nonce values on the portal's callback before signing the user in
c) Send HSTS headers that cover every subdomain of the district's domain
d) Pass the post-sign-in return URL through LocalRedirect so that only local paths are followed
06. A streaming service's ASP.NET Core API seals playback tokens with AES in CBC mode and appends an HMAC-SHA256 tag computed over the IV and ciphertext. When a token returns, the service recomputes the tag, compares it in constant time and decrypts only on a match. The token helper reads one secret from Azure Key Vault and passes it to both the Aes object and the HMACSHA256 constructor. A crypto review of the helper flags a weakness.
What should the review recommend?
a) Derive separate encryption and MAC keys from the vault secret with a key derivation function
b) Compute the tag with HMAC-SHA512 over the IV and ciphertext instead
c) Verify the tag before decrypting and reject any token whose tag fails
d) Rotate the vault secret on a schedule and keep older versions for decryption
07. An HR portal built with ASP.NET Core protects its payroll pages with a policy defined as policy.RequireClaim("EmployeeNumber"). Employees and contractors sign in through the company directory, which issues an EmployeeNumber claim to every account and sets it to N/A for contractors. A contractor opened the payroll summary page without any error.
Which change keeps contractors out of the payroll pages?
a) Add RequireAuthenticatedUser to the same policy before the claim check
b) Rename the claim to a name that contractors are unlikely to guess
c) Have a handler accept only real employee number values
d) Trust claims only when the directory's token issuer has been validated
08. In an ASP.NET Core Razor Pages app for a school district, the Enrollment/Manage page lists student enrollments for any signed-in staff member, and its OnPostDelete handler removes an enrollment. The page model carries [Authorize], and a developer added [Authorize(Roles = "Registrar")] to OnPostDelete. A test shows that a teacher can still delete enrollments. Teachers must keep seeing the list.
Which change limits deletion to registrars?
a) Check the Registrar role with IAuthorizationService inside OnPostDelete
b) Register an AuthorizePage convention for the page path or its folder in Program.cs
c) Move [Authorize(Roles = "Registrar")] from OnPostDelete up to the page model class
d) Replace the handler's role attribute with [Authorize(Policy = "RegistrarOnly")] on OnPostDelete
09. On a recruiting platform, applicants type their name, phone number and a short summary into an ASP.NET MVC form. Recruiters download a nightly CSV of applicants, which the export builds by joining each record's fields with commas, and open it in a spreadsheet application. One applicant's summary was written as a spreadsheet function call, and when a recruiter opened the file, that cell contacted an outside server.
Which change to the export prevents this?
a) Send the export with Content-Disposition: attachment so it saves as a file
b) Wrap each field in double quotes and double any quote character inside it
c) Prefix a quote to cells that start with a formula character
d) HTML-encode each field with HttpUtility.HtmlEncode before writing the file
10. The entry gates at an event venue run a small .NET service on each scanner. The service writes its own HTTP responses, appending the status line and each header as text to the network stream. After a ticket scans, it sends the browser to a results page with a Location header built from the gate query value. A tester's crafted gate value left a cookie in the browser that the service never sets.
Which change to the service prevents this?
a) Reject gate values that contain angle brackets or quote characters
b) Reject any gate value that contains a carriage-return or line-feed character
c) Add a Content-Security-Policy header that blocks inline script
d) HTML-encode the gate value with HttpUtility.HtmlEncode before building the header