# PEPE RUN — audit of `game/engine.mjs`, the free-play page (`web/`) and the six media packs (`media/`) Audited commit: `6083f1b5db4c14344351876ca9d2d057b768ad85` of https://github.com/identity-md-launches/goal-3502-build-audit-deploy-pepe. All file:line references are to that commit (raw files at `https://raw.githubusercontent.com/identity-md-launches/goal-3502-build-audit-deploy-pepe/6083f1b5db4c14344351876ca9d2d057b768ad85/`). Tools: Node v24.21.0 (V8), QuickJS (via `quickjs-emscripten` 0.31, WebAssembly build), Chromium headless shell 159 driven by Playwright 1.x, axe-core 4, Python 3 (stdlib). Audit scripts are not part of this deliverable. Every claim below is either a line of the source or something I ran and observed. ## Summary **Engine: sound.** It is deterministic and integer-only, and all of its generated courses can be passed. The one thing it cannot stop is a bot. - **Determinism.** The engine has no imports. It uses no clock or randomness: `Date`, `Math.random` and `performance` do not appear in `game/engine.mjs`. All arithmetic is on safe integers. Every division is floored or ceiled, and the largest intermediate value is `u*n < 2^32*100`, in `drawInt` (`game/engine.mjs:93-95`). - **Cross-engine check.** I ran the engine in two independent JavaScript engines: V8 (Node) and QuickJS (WebAssembly). Both gave identical `hashState` results for: - all 7 committed fixtures (`game/fixtures/replays.json`, which also match their expected `finalHash`), - a 20,000-tick bot replay (hash `ebcaec01b0742538`, distance 5,519,770 mm), - a 400 km generated course for seed `0xffffffff`. - **Repository tests pass:** `node --test game/test/**` 31/31 and `node --test web/tests/practice.test.mjs` 22/22. Running `node --test web/tests/` (a bare directory) reports a failure, because Node treats the directory itself as a test file. The tests themselves pass. - **Passability.** I wrote my own bot, which only calls the real `createRun`/`stepRun`, and verified every run with `replay`. - It survived 300 seeds × 36,000 ticks (10 min, at least 10.3 km each), 3 seeds × 1 h (about 64.3 km each), and 1 seed for the full 6 h input cap (388,327 m). - No generated obstacle was unavoidable. The narrowest take-off window for a full jump was 4 ticks (67 ms), on `ground_tall` at top speed. For an overhead obstacle, the narrowest duck-start window was 9 ticks. - Difficulty stops rising at about 0.9 km (level 6, `game/engine.mjs:56-57`) and speed at 880 m (`game/engine.mjs:24-26`). From there on the course is statistically stationary. - **Bots.** A perfect bot runs until the replay length cap, `decodeInputs` maxTicks = 1,296,000 ticks (`game/engine.mjs:429`), which is 388,319 m. No person can play for 6 hours, so **any verified-score weekly contest under these rules is won by automation.** Nothing in the engine or replay verification can tell a bot from a person (details in "Automated play" below). - **Replay format.** Bounded at 6 h. However: - Non-canonical encodings are accepted (`1:1,1:1` decodes the same as `1:2`), so the same replay can be written as different strings. - Text length is not capped before `split` (an 8 MB string was parsed for 409 ms before it was rejected). - `deserializeState` does no range checks (`livesLeft: 99` is accepted). **Page: works, with major defects.** It loads with zero console errors and zero failed requests at desktop 1280×800, iPhone 13 portrait (390×664, touch) and landscape (750×342, touch). Taps and keyboard start, jump and duck. Headless Chromium held 60 fps over 600 frames with no long frames. - **The rendering does not match the collision geometry:** - **Overhead obstacles are drawn about 65 px higher than their collision box.** The art shows a gap the runner seemingly can stand through, and standing in it kills (F-01). - Ground obstacle art fills only the lower ~60% of its collision box. - The runner is drawn 4 px above the ground, and its body is 9 px narrower than the engine box at the back. - Background world changes use 500 m instead of the 400/1000 m in `backgrounds.json`. Scroll ratios differ, and the art is stretched so its ground line sits about 32 px above the game's. - Obstacles never animate. All four ground/overhead kinds reuse two pieces of art, stretched. - Only the Classic skin can ever be drawn. - On a portrait phone only 244 px of course is visible ahead of the runner. At top speed that is about 0.27 s of warning, while the engine and its tests assume 800 px. - **Audio:** - There is no cue for `start`, `best`, `pause` or `resume`, so **a new personal best plays no sound at all**. - The `landing`, `revive` and `menu` cues are never used. - **Security:** No CSP, either as a header or a `` tag. No script injection was found: every displayed value goes through `textContent`, and hostile `localStorage` values rendered inert (no dialogs, no elements). - **Accessibility:** axe reports 1 rule, `color-contrast` (serious, 6 nodes): 9 px `#1d7a0c` text on `#0b120b`, about 3.47:1. **Media: builds and checks reproduce, but packs are incomplete and need licences.** - **Checks I ran:** - Characters: 22/22 checks pass. - Backgrounds: check passes, with 0 seam mismatches on all 9 layers. - Obstacles: no check exists, but the build regenerates byte-identical PNG and JSON. - SFX: the documented `check.js` and `synthesize.js` crash under the repo's `"type": "module"`. Run as `.cjs` copies, the check passes and the regenerated WAV is byte-identical. - Music: `measure.mjs` fails with `ERR_MODULE_NOT_FOUND`, because its decoder is not vendored. - Logo: has no check at all. - **Content gaps:** - The obstacle set is too small for the engine's four kinds. - Characters have no hit/death or Royal-revive frames. - The skin shop has no icons or thumbnails. - Music has no menu or game-over track. - SFX lacks start, best, pause, purchase and jackpot cues. - **Licence and provenance gaps:** - No pack carries a public licence. Characters uses an owner-to-set `LicenseRef`. Obstacles says "original work contributed". - Backgrounds, logo, music and SFX have no licence statement. - There is no repository `LICENSE` file. - The "Pepe" name is explicitly left to legal review. ## Findings Severity scale: Critical = breaks fairness or the paid product; High = visible gameplay defect or blocking gap; Medium = defect with workaround; Low = polish; Info = observation. | id | severity | where (file and line) | what is wrong | how you saw it | fix | |---|---|---|---|---|---| | F-01 | Critical | `web/js/render.mjs:152-156`; `media/obstacles/obstacles.json:128-146`; `game/engine.mjs:47` | The overhead obstacle's 64×64 cell is stretched over the 64×120 collision box. The solid art occupies only cell rows 9–28, so the visible gate floats about 97 px above the ground. The collision box starts at 30 px. A standing runner (44 px) dies in the empty space under the art. | Chromium screenshot at tick 1226, seed 12345, with the engine boxes overlaid: the magenta box reaches down to 30 px, the drawn gate ends far above. Arithmetic: art bottom = 30 + 120×(64−28)/64 ≈ 97.5 px. | Draw the overhead art with its own anchor (`top-center`, `obstacles.json:135`) and size, and fill the box down to `bottomPx` with solid art: a hanging bar or beam reaching down to 30 px. Or change the engine box to match the art. Either way, assert in a test that the visible bounds equal the collision box. | | F-02 | High | `web/js/render.mjs:152-156`; `media/obstacles/obstacles.json:65-71` | Ground obstacles are drawn by stretching the whole 64×64 cell (solid bounds x6–59, y25–62) over 24×30, 22×46 or 56×28 boxes. The top ~39% of each collision box (11.7 px of 30, 18 px of 46) has no art, so the runner dies on visibly empty air. The aspect ratio also distorts the pixel art. | Screenshots `desktop-death` and `stop-6620`: the spikes fill only the lower part of the magenta box. Computed from `solidBounds`. | Crop the `solidBounds` rect, not the cell, and draw it at the box size. Better: make one piece of art per engine kind at the exact box size (see M-03). | | F-03 | High | `web/js/render.mjs:7-9,172-173`; `media/characters/characters.json:21-30,190-230` | Runner placement ignores the atlas anchor `(32,60)`. The cell bottom (y=64) is placed on the ground line, so the feet float 4 px. The front foot is assumed to be at cell x=44. The engine box is 32 wide (`game/engine.mjs:37`), so it spans cell x 12–44, while the atlas body hitbox is x 21–45 (w 24). That leaves 9 px of collision behind the drawn body. Duck height is 24 in the engine and 25 in the atlas. Hitbox widths differ in every pose: 24, 25, 22, 19. | Screenshots: the cyan engine box extends behind the frog, the frog's head is about 4 px above the box, and the feet are above the green ground line. Numbers come from the JSON and the render code. | Place the cell so its anchor (32,60) sits on the physics foot point. Then either set `PLAYER_WIDTH_PX` to the art's body width, or re-rig the art to 32 px. Add a test comparing `playerHitbox()` with `characters.json.hitboxes` for every pose. | | F-04 | High | `web/js/render.mjs:12,46-49,121-129`; `media/backgrounds/backgrounds.json:7,10,14,23,32`; `media/backgrounds/README.md:3,5` | The renderer does not follow the background metadata: | Bot-driven run in Chromium. Screenshots at 450 m, 560 m, 1,050 m and 1,505 m showed Lily Marsh, Neon, Observatory, then Lily Marsh again. The background ground is visibly about 30 px above the green line. | Read `backgrounds.json`: choose the world by `startDistanceMeters` (last world loops) and use its `scrollRatios` and cell rectangles. Scale by an integer, or align cell y=104 to `GROUND_Y` and fill the rest. | | F-05 | High | `web/js/render.mjs:178`; `media/characters/characters.json:19,1755-1757`; `game/engine.mjs:35-36,110-112` | Only atlas row 0 (Classic) is ever drawn, so the 20 permanent skins cannot be displayed. The atlas also has a 22nd row, `royal`, while `playerHitbox` accepts skin ids 0..20 only. How a Royal pass maps to a cosmetic row is undefined. | Code reading. `characters.json` lists rows 0–21 (classic, 20 permanent skins, royal). | Pass the owned skin id to the renderer and draw row `skins[id].row`. Decide and document whether `royal` is a skin (then extend `SKIN_COUNT` or exempt it) or only an overlay. | | F-06 | High | `web/js/audio.mjs:12-21`; `web/js/main.mjs:51,54,57-59`; `media/sfx/cues.json:1-30` | Cue aliases do not match the pack. `start`, `best`, `pause` and `resume` resolve to `null`, so starting a run is silent. On a new personal best `main.mjs:54` plays `best` *instead of* `death`, so the run ends **in silence**. The pack's `landing`, `revive` and `menu` cues are never used. | `resolveCue` run in Node against `cues.json`: start=null, best=null, pause=null, resume=null; jump, duck, milestone and death resolve. | Map start→`menu` (or add a `start` cue), best→play `death` then a `best` cue, landing→the engine's airborne→grounded edge, revive→Royal save (`savedAtTick`). Add a unit test that every emitted event resolves to a cue. | | F-07 | High | `web/js/render.mjs:5,82-83`; `game/engine.mjs:53`; `game/test/reachability.test.mjs:13,78-82` | Visible look-ahead depends on the screen's aspect ratio. The engine and test assume obstacles are visible 800 px ahead, giving at least 30 ticks of reaction. The page shows: Portrait players get roughly 40% less warning than desktop players on the same seed. That matters for a ranked contest. | Measured in Chromium: `viewW − RUNNER_FRONT_X` per viewport (`report.json` layout). | Fix the logical view width (e.g. ≥ 800 px wide plus letterboxing), or set a minimum width and shrink the vertical scale on portrait. Or move the runner further left. Then make the reaction test use the real rendered width. | | F-08 | Medium | `web/js/render.mjs:150-156`; `media/obstacles/obstacles.json:21,84` | Obstacles never animate. The renderer picks a fixed column per kind via `hashKind(kind) % 4`: ground_small→3, ground_tall→1, ground_wide→3, overhead→0. It treats the 4 animation frames (120 ms each) as kind variants, so ground_small and ground_wide even share a frame. | Hash computed in Node; code reading; screenshots show static art. | Choose the row by kind and the frame by `floor(timeMs/120) % 4`. | | F-09 | Medium | `web/js/render.mjs:39-44,178`; `media/characters/characters.json:137-189` | Character animation timing differs from the metadata: | Code against JSON. Screenshots show correct rise/fall frames mid-air. | Derive frame timing from `animations[*].frameMs` and speed. Apply `bobPx`. Choose rise/fall from `vyQ8` exposed in the snapshot. | | F-10 | Medium | `web/index.html:1-12` (no `Content-Security-Policy` meta); served without a CSP header | There is no content security policy. The page has no inline script or style, so a strict policy is free today. Without one, any future DOM-sink bug, especially once wallet and API code lands, is directly exploitable. | Playwright: response header `content-security-policy` = null and no ``. `grep` finds no `innerHTML`, `eval`, `new Function` or `document.write` in `web/`. | Serve `Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self'; media-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`. Add each RPC/API origin to `connect-src` explicitly when wallet play is enabled. Also send `X-Content-Type-Options: nosniff` and `Referrer-Policy: no-referrer`. | | F-11 | Medium | `web/js/main.mjs:12`; `web/js/render.mjs:16-21`; `web/js/audio.mjs:5-9`; `web/index.html:9,16` | The page loads `../../game/engine.mjs` and `../../media/*` relative to `web/js/`, so it works only when the **repository root** is served and the page is at `/web/index.html`. Publishing `web/` as the site root (e.g. at peperun.imd.site/) leaves the engine unreachable and the game will not start. | It worked when I served the repo root with `python3 -m http.server`: all requests returned 200. The dependency follows from the code. | Add a build step that copies `game/engine.mjs` and `media/` into the published directory, and test the published tree, not the repo. | | F-12 | Medium | `web/css/practice.css:6,58,86` | Contrast: HUD labels and the overlay hint are 9 px `#1d7a0c` on `#0b120b`, about 3.47:1 (3.68:1 on `#050805`). axe `color-contrast` reports it as serious on 6 nodes. | axe-core 4 in Chromium at all three viewports. Ratio computed with the WCAG relative-luminance formula. | Use a lighter green (e.g. the `--green` value already used for HUD values) or a larger size for `dt` and `.ov-hint`. | | F-13 | Low | `web/js/storage.mjs:39,57`; `web/js/main.mjs:98` | Stored runs are validated only on `distanceMm`. A tampered `at` field shows "Invalid Date" in the ranking. There is no injection: all fields go through `textContent`. | Injected `{"at":"