The Lawfare Academy

Lawfare Group → Knowledge Institute → Lawfare Academy

← CS 220 — Web Applications, SQL and Software Engineering

Weeks 1–2

The web request, semantic HTML and accessibility

Learning objectives

  • Explain and trace the mechanisms in the web request, semantic html and accessibility.
  • Apply the method to the worked example and changed-condition exercise.
  • Identify assumptions, failure cases and the evidence needed to justify a result.

A web application crosses a network boundary. A browser sends a request; a server responds with a status, headers and a representation. HTML gives content semantic structure, CSS controls presentation and JavaScript adds behavior. A polished appearance does not establish that the underlying form is accessible or that its data is trustworthy.

Start from native elements. A button expresses an action, an anchor expresses navigation and a label associates a form control with its name. Replacing a button with a clickable div requires rebuilding keyboard and accessibility behavior that the native element already provides. Heading order should reflect document structure rather than font size. A user should understand a control without relying only on color, position or a mouse.

Browser validation improves feedback but does not protect the server. A client can bypass a form entirely and send a request directly. Validate submitted data again at the server boundary, including type, length, allowed values and relationships. Preserve entered values after an error where appropriate and identify the specific field needing correction. Test keyboard navigation, narrow screens and error states rather than only a successful desktop screenshot.

Worked reasoning The labels are explicitly connected to inputs by matching for and id attributes. Names determine submitted field names. min and step describe client constraints, but the server must still reject negative or fractional hours and overlong descriptions. This form is a markup example; it requires an implemented POST /orders handler before it can save anything.

Extended teaching and laboratory

A browser form is a client convenience. A caller can send a request without using that form, alter hidden fields or repeat a submission. The server must establish identity, permission and domain validity independently. Distinguish malformed input, unauthenticated requests, unauthorized object access and conflicts; they require different handling even if all must avoid exposing private details.

Accessibility is also part of the interface contract. A visual caption is not necessarily a programmatic label. Associate labels and controls, identify errors in text, and preserve usable focus after errors. Client validation can improve that experience while server validation remains authoritative.

Worked problem An order form contains a hidden owner_id and min=0 on hours. A signed-in customer changes owner_id to another customer and sends hours=−3. Design the acceptance boundary.

Step-by-step reasoning 1. Resolve the customer from a verified server session. Do not adopt the body owner_id as authority.

  1. Validate hours against the server’s type and range contract. A client-side minimum cannot establish that this request satisfies it.
  1. Reject the request before inserting a row. Return an understandable error without revealing another customer’s records.
  1. On the form, connect the error to the hours control and retain the submitted non-sensitive values. Test a raw HTTP request as well as the browser path.

Apply the idea

An order form contains a hidden owner_id and min=0 on hours. A signed-in customer changes owner_id to another customer and sends hours=−3. Design the acceptance boundary.

A valid request is repeated after the browser loses the response. Explain how to avoid accidentally creating two orders while preserving a legitimate second order.

Read the worked reasoning

Use a stable submission identifier with a uniqueness constraint and a stored payload fingerprint. An identical retry returns the original result. A conflicting payload under the same identifier is rejected. A legitimate new order receives a new identifier. Disabling the submit button alone cannot protect against network retries or multiple clients.

Check understanding

What protects the server from a bypassed form?

  1. Server-side validation and authorization
    Feedback

    Client controls are useful feedback but are not a trust boundary.

  2. The required attribute alone
    Feedback

    A custom HTTP client can omit browser validation.

  3. A green submit button
    Feedback

    Color communicates no server-side guarantee.

Further reading

Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Study MDN Getting Started and Core modules: web standards, semantic HTML, forms, CSS layout and accessibility. Complete CS50 Web HTML/CSS and Git. Complete the corresponding source exercises.

My learning →