skip to content

target navigation · lesson 5 of 8 · sources checked 2026-11-20

forms and in-page actions

This lesson shows the fields and checks of a form, the signals that a submit gives to a site, and how to confirm an action.

status of this lesson: documented in my test system

purpose

A form sends more to the server than the fields that a human sees. Each part of a submit is a signal for the site. A click can also change the page and do nothing on the server.

objectives

  1. Name the signals that a hidden field, a form token, and the submit headers give to a site.
  2. Explain why a value that a script writes takes effect only after an input event.
  3. Confirm an in-page action from the network, not from the page.
  4. Identify a silent no-op in the result of an action.

new terms

target
A site or API that an operator collects data from.
honeypot element
An element that a human cannot see or reach, put in a page to catch automation.
automation artifact
A signal that an automation tool leaks and that a detector can read.
one-time token
A token in a link or a form that the site accepts only one time.
trusted event
An input event that the browser marks with `isTrusted: true` because it came from the user agent, not from a page script.
fetch metadata
The `Sec-Fetch-*` request headers that a browser sends to describe the context of a request.
silent no-op
An action that the site accepts with no error but does not carry out.
selector
An expression that finds elements in a DOM tree.

how it works

A form on a target has more parts than the fields that a human sees. The server reads each part of the submit:

partwhat the server reads
Visible fieldsThe values that the user types or selects
Hidden fieldsValues that the page sets, and trap fields
Form tokenA value that the server issued with the page
Request headersThe context of the request, for example Origin
The action resultThe response of the server, not the change on the page

the trap field

A site can put a field in a form that a human cannot see or reach. This field is a honeypot element. A human leaves it empty. But a script that fills each input, for example by a loop over all fields, fills it too.

example A sign-up form has a field email2 with no size and no label. A site reads a submit with a value in email2 as automation.

A filled hidden field is a strong automation artifact. Thus a client must check that a field is visible before it fills the field.

the form token

Many forms carry a token in a hidden field. The OWASP cheat sheet gives the synchronizer token pattern. The token can come back in a hidden field, and the cheat sheet advises the server to refuse a request without it OWASP, source 1.

A one-time token works only one time. For example, a client that sends the same form two times gets a refusal on the second submit, because the first submit used the token.

a value takes effect after an event

A page framework can keep its own copy of a field. Such a framework copies the value of the field into that copy only on an input event. Thus a script that sets the value alone changes the field, but not the form state.

In the DOM Standard, the isTrusted value of an event is true when the user agent sends it. It is false for an event that a script sends with dispatchEvent() WHATWG, source 2.

Thus an event from a script is not a trusted event, and a page script can see the difference. The code example shows the two reads and this signal.

The form code of the benchmark platform, my test system, sends an input event after it writes a value. Then it reads the value a second time. For example, a token value that is in the field but not in the form state gives a fail at the second read.

the request headers

A browser describes the context of each request with fetch metadata. The W3C document defines four headers. The values of Sec-Fetch-Site are cross-site, same-origin, same-site, and none W3C, source 3.

A site can check these headers before it reads the form fields. The OWASP cheat sheet calls Sec-Fetch-Site the primary signal against cross-site request forgery. It also advises the server to check that the Origin header has the scheme, the host, and the port of the target OWASP, source 1.

example A browser sends a form submit with Sec-Fetch-Site: same-origin. A raw HTTP client sends the same fields with no Sec-Fetch-Site header. The site can separate the two requests by the headers alone.

confirm the action from the network

A click can change the page and still do nothing on the server. For example, a cart count on the page can go up with no item on the server. The site accepts the action with no error, but does not carry it out. This is a silent no-op.

example An add step clicks the add control of an item with no selected size. The page shows no error, and the response of the add endpoint holds no item. The cart stays empty.

Thus a flow confirms each action from the response of the server, not from the page. First, it selects the variant of the item. Then it reads the response of the add endpoint. On a site that scores risk, a silent no-op can also be a block, not a fault of the selector.

forms with many steps

status of this section: from a public source

A form can span many pages. The form wizard of django-formtools keeps the data of each step in a store until the user submits the last form. It can keep the data in a web session on the server or in browser cookies django-formtools project, source 4.

For example, when the cookie of step 1 is missing, the wizard has no valid data for step 1. At the last submit, it sends the user back to step 1. Thus the state rules of a flow also apply inside one form.

the two sides

automation sidedetection side
A visibility check before a fill keeps the client away from a trap field. A read of the server response confirms that an action took effect.A filled hidden field is a near-certain sign of automation. A missing fetch metadata header or a wrong Origin value separates a raw HTTP client from a browser. The rhythm of typing is a behavior signal. An input event from a script has isTrusted false.

design decisions

optiongaincostwhen it is correct
Fill only visible fieldsThe client does not fill a trap field.Each field must have a visibility check.Each form on a target
Send the form from a browserThe request has the fetch metadata headers and the Origin of the page.A browser costs more time and memory than a raw client.Forms on sites that check the request context
Send the form from a raw HTTP clientEach submit is fast and small.The missing headers and the missing token are signals.Only forms with no token and no context check, in your own lab
Confirm each action from the networkA silent no-op shows as a fail.The flow must know the expected response.Each action that changes state on the server

diagram

the fields and checks of a form submit, from the page to the network confirmation

  1. Visible fieldsThe values that the user types or selects.
  2. Hidden trap fieldMust stay empty. A value marks automation.
  3. Form tokenMust be present, valid, and not used before.
  4. Fetch metadata headersSec-Fetch-Site must agree with a submit from the page.
  5. Origin headerMust name the site of the form.
  6. Network confirmationThe flow reads the server response, not the page.
A submit passes only when each part agrees with a browser on the page of the form.source: My model of the checks of a form submit

code example

The example writes a synthetic token into a field of a synthetic form. It reads the form state, sends an input event, and reads the state a second time.

example The form, the field, and the token are synthetic. No part describes a real product.

m06-x07-input-event.tstypescript

Write a token value into a controlled field, send an input event, and read the form state a second time. Show the signal that the event leaves.

// Synthetic model of a form field that a page framework controls.
// The framework copies the field value into its state only on an "input" event.
type FormState = Record<string, string>;

class Field extends EventTarget {
  name: string;
  value = "";
  constructor(name: string) {
    super();
    this.name = name;
  }
}

function bindToState(field: Field, state: FormState, log: string[]): void {
  field.addEventListener("input", (e) => {
    state[field.name] = field.value;
    log.push(`input event on "${field.name}", isTrusted=${e.isTrusted}`);
  });
}

// The argument is a synthetic token value.
const tokenValue = process.argv[2] ?? "synthetic-token-0001";
const state: FormState = { token: "" };
const log: string[] = [];
const field = new Field("token");
bindToState(field, state, log);

// Write 1: the script sets the field value only.
field.value = tokenValue;
console.log(`read 1: field="${field.value}" state="${state.token}"`);

// Write 2: the script sends an input event. Then it reads the state again.
field.dispatchEvent(new Event("input", { bubbles: true }));
console.log(`read 2: field="${field.value}" state="${state.token}"`);

// The signal that the method leaves: an event that the user agent did not send.
for (const line of log) console.log(`signal: ${line}`);
const ok = state.token === tokenValue;
console.log(ok ? "result: the form state holds the token" : "result: the form state does not hold the token");

output

Two reads of the field and the form state, one signal line, and the result.

read 1: field="synthetic-token-0001" state=""
read 2: field="synthetic-token-0001" state="synthetic-token-0001"
signal: input event on "token", isTrusted=false
result: the form state holds the token

I ran the code with the Node runtime and the flag --experimental-strip-types, with the argument synthetic-token-0001. Read 1 shows the value in the field and an empty form state. Read 2 shows the value in both. The signal line shows that the event did not come from the user agent.

failure modes

problemcausecorrection
The site refuses each submit with no clear reason.The client filled a hidden trap field.Check that a field is visible before you fill it.
The form sends an empty token.The script set the field value, and the framework did not copy it into the form state.Send an input event after the write, and read the form state again.
An add step reports a pass, and the cart is empty.The add did nothing, because the flow selected no variant.Select the variant first. Confirm the add from the response of the add endpoint.
The second submit of a form fails.The form token is a one-time token, and the first submit used it.Get a new page and a new token for each submit.
A raw client gets refusals that a browser does not get.The request has no fetch metadata headers or a wrong Origin.Record the request headers of each submit, and compare them with a browser submit in your lab.

check questions

  1. Name the signal that each part of a submit can give to a site: a hidden trap field, a form token, and the request headers.

    sample answer

    A filled hidden trap field is a strong automation artifact. A missing or used form token makes the server refuse the request. A missing fetch metadata header or a wrong Origin value separates a raw HTTP client from a browser.

  2. Explain why a script that sets the value of a field can send an empty value with the form.

    sample answer

    A page framework can keep its own copy of the field. Such a framework copies the value into that copy only on an input event. A script that sets only the value changes the field, but not the form state that the form sends.

  3. An add step clicks the add control, and the page shows a new cart count. Which check confirms the add?

    1. The new cart count on the page
    2. No error message on the page
    3. The response of the add endpoint holds the item
    answer

    c. The response of the add endpoint holds the item

    The page can change while the server does nothing. Only the response of the server shows that the action took effect.

  4. A site accepts an add with no error, and the cart stays empty. What is this result?

    1. A silent no-op
    2. A served challenge
    3. A pass of the step
    answer

    a. A silent no-op

    The site accepted the action with no error but did not carry it out. On a site that scores risk, it can also be a block.

exercise

exercise Do this task in your own lab, with synthetic data only. Do not send a request to a site.

  1. Save the code example in an empty folder of your lab.
  2. Remove the line that sends the input event.
  3. Run the code with Node and the flag --experimental-strip-types.
  4. Record the two reads and the result.
  5. Put the line back, and run the code again.
  6. Write which read shows the form state that the server gets.
  7. Write the signal that a page script can read in the second run.
sample answer

This model answer uses the synthetic form of the code example.

Without the event, both reads show the value in the field and an empty form state. The result is that the form state does not hold the token, and no signal line prints. With the event, read 2 shows the token in the form state. The form state is the value that the server gets, thus read 2 is the correct check. In the second run, a page script can read isTrusted false on the input event.

sources

  1. Cross-Site Request Forgery Prevention Cheat Sheet, OWASP, documentation, read 2026-11-20
  2. DOM Standard, WHATWG, standard, read 2026-11-20
  3. Fetch Metadata Request Headers, W3C, draft, read 2026-11-20
  4. Form wizard, django-formtools project, documentation, read 2026-11-20
  5. My model of the parts and checks of a form submit, 2026-11 (not public).
  6. Benchmark platform, code (my test system): an input event after a write and a second read of the value, 2026-11 (not public).