Nullgate

Amazon ACIC Solver API

ACIC costs $1.50 per 1,000 generated solutions (all prices).

For automatic PoW/WAF verification and continuation, use POST /solve with type: "amazon_acic". The sections below cover the manual SDK flow.

Advanced: complete the flow with your clients

An Amazon ACIC page asks for a proof of work (PoW), an AWS WAF image puzzle, or a PoW followed by a WAF puzzle. Each WAF round shows nine images and one query.

How the flow works

  1. acic.discover() finds the challenge configuration in the Amazon page.
  2. Your client sends the first ACIC request. The answer header amz-aamation-resp names the current stage.
  3. PoW stage: acic_pow() / acicPow() asks Nullgate for the proof.
  4. WAF stage: your client fetches the puzzle from AWS. For each round, acic_waf() / acicWaf() asks Nullgate for an answer, and your client sends it to AWS. At the end, AWS returns a voucher.
  5. Your client sends the PoW answer or the voucher to ACIC. Steps 3–5 repeat until the stage is PASS.
  6. Your client submits the original continuation form with the final ACIC token.

Only acic_pow() / acicPow() and acic_waf() / acicWaf() call Nullgate. The other acic helpers work locally.

1. Prepare your clients

The helpers are in Git main, not in the v2.0.0 tag.

Python
pip install --upgrade git+https://github.com/nullgate-club/nullgate-sdk-py@main
TypeScript
npm install github:nullgate-club/nullgate-sdk-ts#main

Keep your existing Amazon client, cookies, proxy and User-Agent. Pass the response URL after redirects.

  • Python: aws is a separate client with the same proxy and User-Agent, but no Amazon cookies or authorization headers.
  • TypeScript: fetchTarget must retain Amazon cookies for credentials: "include" and send no cookies or authorization headers for credentials: "omit".
  • Never attach the Nullgate API key to Amazon or AWS requests.
  • Do not log request URLs, bodies or amz-aamation-resp: they contain challenge state and tokens.

2. Add the complete flow

Python
"""Complete ACIC PoW/WAF through caller-owned Amazon and AWS HTTP clients."""

import json
import time

import httpx

from nullgate import Nullgate, TargetRequest, acic

POW_TYPES = {
    "PROOF_OF_WORK_LEVEL_3",
    "PROOF_OF_WORK_LEVEL_3_CHAIN_WAF_ADVERSARIAL_SYNTHETIC_GRID_V2_LEVEL_2",
}
WAF_TYPES = {
    "WAF_ADVERSARIAL_SYNTHETIC_GRID_V2_LEVEL_2",
    "WAF_ADVERSARIAL_SYNTHETIC_GRID_V2_LEVEL_3",
}


def solve_acic(
    ng: Nullgate,
    amazon: httpx.Client,
    aws: httpx.Client,
    entry: httpx.Response,
) -> httpx.Response:
    """Handle an ACIC page, or return a page without ACIC unchanged."""
    setup = acic.discover(str(entry.url), entry.text)
    if setup is None:
        return entry

    def send(request: TargetRequest) -> httpx.Response:
        response = amazon.request(
            request.method,
            request.url,
            headers=request.headers,
            content=request.body,
            follow_redirects=False,
        )
        if response.status_code != 200:
            raise RuntimeError(f"ACIC returned HTTP {response.status_code}")
        return response

    response = send(setup.start())
    seen = set()
    while True:
        state = acic.parse_result(response.headers)
        if state is None:
            raise RuntimeError("Amazon returned no ACIC result header")
        if state.action_type == "PASS":
            request = setup.continuation(state)
            return amazon.request(
                request.method,
                request.url,
                headers=request.headers,
                content=request.body,
                follow_redirects=True,
            )
        if state.action_type in seen:
            raise RuntimeError("ACIC repeated a stage; stop instead of paying again")
        seen.add(state.action_type)
        if state.action_type in POW_TYPES:
            proof = ng.acic_pow(state.action_type, response.text)
            proof.wait()
            answer = proof.response
        elif state.action_type in WAF_TYPES:
            waf = acic.discover_waf(str(response.url), response.text)
            if waf is None or waf.rounds_required not in (2, 3):
                raise RuntimeError("Unsupported WAF view or round policy")
            problem_response = aws.get(waf.problem_url, headers=waf.headers)
            problem_response.raise_for_status()
            problem = problem_response.json()
            presented_at = time.monotonic()
            for _ in range(waf.rounds_required):
                selection = ng.acic_waf(problem)
                body = selection.verification_body(
                    problem,
                    elapsed_seconds=time.monotonic() - presented_at,
                    locale=waf.locale,
                )
                verified = aws.post(
                    waf.verification_url(problem),
                    headers=waf.headers,
                    content=json.dumps(body),
                )
                verified.raise_for_status()
                result = verified.json()
                voucher = result.get("captcha_voucher")
                if isinstance(voucher, str) and voucher:
                    answer = state.voucher_response(voucher)
                    break
                if result.get("success") is not True or not isinstance(
                    result.get("problem"), dict
                ):
                    raise RuntimeError("AWS rejected the WAF answer")
                problem = result["problem"]
                presented_at = time.monotonic()
            else:
                raise RuntimeError("AWS returned no voucher within its round policy")
        else:
            raise RuntimeError("Unsupported ACIC stage")
        response = send(setup.answer(state, answer))
TypeScript
import {
  acic,
  acicWafVerificationBody,
  Nullgate,
  type TargetRequest,
} from "@nullgate/sdk";

const stageKinds: Readonly<Record<string, "pow" | "waf">> = {
  PROOF_OF_WORK_LEVEL_3: "pow",
  PROOF_OF_WORK_LEVEL_3_CHAIN_WAF_ADVERSARIAL_SYNTHETIC_GRID_V2_LEVEL_2: "pow",
  WAF_ADVERSARIAL_SYNTHETIC_GRID_V2_LEVEL_2: "waf",
  WAF_ADVERSARIAL_SYNTHETIC_GRID_V2_LEVEL_3: "waf",
};

/** fetchTarget owns target cookies, proxy, User-Agent and timeouts. */
export async function solveAcic(
  ng: Nullgate,
  fetchTarget: typeof fetch,
  entry: Response,
): Promise<Response> {
  const setup = acic.discover(entry.url, await entry.clone().text());
  if (!setup) return entry;

  const send = async (
    request: TargetRequest,
    redirect: "error" | "follow" = "error",
  ): Promise<Response> => {
    const response = await fetchTarget(request.url, {
      method: request.method,
      headers: request.headers,
      body: request.body as BodyInit | null,
      credentials: request.credentials,
      signal: request.signal,
      redirect,
    });
    if (redirect === "error" && response.status !== 200)
      throw new Error(`ACIC returned HTTP ${response.status}`);
    return response;
  };

  let response = await send(setup.start());
  const seen = new Set<string>();
  while (true) {
    const state = acic.parseResult(response.headers);
    if (!state) throw new Error("Amazon returned no ACIC result header");
    if (state.actionType === "PASS")
      return send(setup.continuation(state), "follow");
    if (seen.has(state.actionType))
      throw new Error("ACIC repeated a stage; stop instead of paying again");
    seen.add(state.actionType);
    let answer: string;
    if (stageKinds[state.actionType] === "pow") {
      const proof = await ng.acicPow({
        challengeType: state.actionType,
        html: await response.text(),
      });
      await proof.wait();
      answer = proof.response;
    } else if (stageKinds[state.actionType] === "waf") {
      const waf = acic.discoverWaf(response.url, await response.text());
      if (!waf || ![2, 3].includes(waf.roundsRequired))
        throw new Error("Unsupported WAF view or round policy");
      const fetched = await fetchTarget(waf.problemUrl, {
        headers: waf.headers,
        credentials: "omit",
        redirect: "error",
      });
      if (!fetched.ok) throw new Error(`AWS returned HTTP ${fetched.status}`);
      let problem: Record<string, unknown> = await fetched.json();
      let presentedAt = performance.now();
      let voucher: string | undefined;
      for (let round = 0; round < waf.roundsRequired; round++) {
        const selection = await ng.acicWaf({ problem });
        const body = acicWafVerificationBody({
          problem: {
            state: problem.state,
            key: problem.key,
            hmac_tag: problem.hmac_tag,
          },
          solution: selection.clientSolution,
          elapsedMs: performance.now() - presentedAt,
          locale: waf.locale,
        });
        const verified = await fetchTarget(waf.verificationUrl(problem), {
          method: "POST",
          headers: waf.headers,
          body: JSON.stringify(body),
          credentials: "omit",
          redirect: "error",
        });
        if (!verified.ok)
          throw new Error(`AWS returned HTTP ${verified.status}`);
        const result: Record<string, unknown> = await verified.json();
        if (
          typeof result.captcha_voucher === "string" &&
          result.captcha_voucher
        ) {
          voucher = result.captcha_voucher;
          break;
        }
        if (
          result.success !== true ||
          !result.problem ||
          typeof result.problem !== "object" ||
          Array.isArray(result.problem)
        )
          throw new Error("AWS rejected the WAF answer");
        problem = result.problem as Record<string, unknown>;
        presentedAt = performance.now();
      }
      if (!voucher)
        throw new Error("AWS returned no voucher within its round policy");
      answer = state.voucherResponse(voucher);
    } else {
      throw new Error("Unsupported ACIC stage");
    }
    response = await send(setup.answer(state, answer));
  }
}

3. Continue your application

Python
from nullgate import Nullgate
from acic_flow import solve_acic

with Nullgate() as ng:
    response = solve_acic(ng, amazon_http, aws_http, response)
response.raise_for_status()
TypeScript
import { Nullgate } from "@nullgate/sdk";
import { solveAcic } from "./acic_flow.mts";

response = await solveAcic(new Nullgate(), fetchTarget, response);
if (!response.ok) throw new Error(`Amazon returned HTTP ${response.status}`);

PASS confirms challenge acceptance, not account authentication. The page can still require FWCIM.

What the helpers preserve

discover() reads the literal acic.setupACIC(...) configuration and the hidden continuation fields. Pass the current parse_result() / parseResult() result to answer(): the context and session token can change between stages.

Each AWS answer uses the current problem's state, key, hmac_tag and region. A successful intermediate round is not a voucher.

Do not put the voucher or image indexes into the continuation form. continuation() requires PASS, inserts the final ACIC sessionToken, and retains the form's CSRF, duplicate and blank fields. Its action must be a same-origin POST.

The helpers do not execute JavaScript, fetch scripts, authenticate accounts or retry rejected answers. Missing setup or header returns None / null. Malformed, ambiguous or unsupported configuration raises an error.

Billing and failures

  • Each generated PoW or WAF round costs one amazon.acic operation. There is no separate classifier charge.
  • A generated solution is charged even if Amazon or AWS rejects it.
  • Send PoW only after send_at / sendAt. wait() handles this. Do not JSON-encode proof.response again.
  • Supported PoW types are PROOF_OF_WORK_LEVEL_3 and PROOF_OF_WORK_LEVEL_3_CHAIN_WAF_ADVERSARIAL_SYNTHETIC_GRID_V2_LEVEL_2.
  • Supported WAF profiles are gridcaptcha-v2-5-0.15-0 and gridcaptcha-v2-5-0.2-0, with two and three rounds respectively. Each selection contains five zero-based image indexes.
  • Arkose and unknown solver profiles return HTTP 501 unsupported without a charge. Local discovery does not mean that a policy is solvable.
  • The prepared ACIC requests use the observed accepted fwcimBlob: null path without md telemetry. This does not establish that these fields are optional for every Amazon policy.

Request fields and error envelopes: HTTP reference. Complete examples: Python, TypeScript.