[GH-ISSUE #7500] Package background refreshes (Noodle, Slurp) get 401 on Android app installs #4178

Closed
opened 2026-10-21 06:12:07 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @SpicyMarinara on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7500

Originally assigned to: @SpicyMarinara on GitHub.

Summary

On Android installs set up by the Marinara app, package background jobs that call their own routes get 401 Android local authentication required. Noodle's and Slurp's scheduled refreshes are the known cases, so their feeds never refresh in the background on Android.

This has the same cause as #7475, but #7484 fixes only the autonomous scheduler, so it is filed separately.

Cause

runCapabilityInternalRoute (packages/server/src/services/capability-packages/capability-route-registration.service.ts) calls app.inject(), which arrives from 127.0.0.1. It adds only the package's internal-route token (x-marinara-internal-route). The global androidLocalAuthHook runs before the route-level onRequest that honors that token. It sees a loopback request with no session cookie and no x-marinara-android-secret, so it returns 401.

Callers (Marinara-Agents origin/staging 486f3667): packages/noodle/.../noodle-refresh-scheduler.service.ts:139 and packages/slurp/.../slurp-refresh-scheduler.service.ts:140, both through runInternalRoute({ method: "POST", url: "/api/<id>/refresh", ... }).

Reproduction

A scratch Fastify app with the real androidLocalAuthHook and the real registerCapabilityPrivilegedRoutes registered a fake noodle package with POST /refresh. With MARINARA_ANDROID_SECRET set to 64 hex characters, runCapabilityInternalRoute(app, "noodle", { method: "POST", url: "/api/noodle/refresh" }) returned 401. With the variable unset, it returned 200.

Desktop, Docker, LAN and manual Termux installs don't set MARINARA_ANDROID_SECRET, so they are not affected.

Fix needs a choice

  1. Add androidLocalAuthInjectHeaders() (added in #7484) to the inject in runCapabilityInternalRoute. This is a one-line fix, but it hands the install secret to the package's route handler in request.headers. Packages already run in-process, but a package that logs request headers would then write the secret to its logs.
  2. Let androidLocalAuthHook accept a request that carries a valid, active internal-route token for that URL's package prefix. The secret never reaches package code, and the bypass stays limited to the package's own routes, which runInternalRoute already allows.

Option 2 looks safer. Either fix needs a regression in scripts/regressions/android-local-auth.regression.ts that runs runCapabilityInternalRoute with the Android secret set.

Engine-owned: this is the capability route API and local auth, not package code. No Marinara-Agents change is needed.

Originally created by @SpicyMarinara on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7500 Originally assigned to: @SpicyMarinara on GitHub. ## Summary On Android installs set up by the Marinara app, package background jobs that call their own routes get `401 Android local authentication required`. Noodle's and Slurp's scheduled refreshes are the known cases, so their feeds never refresh in the background on Android. This has the same cause as #7475, but #7484 fixes only the autonomous scheduler, so it is filed separately. ## Cause `runCapabilityInternalRoute` (`packages/server/src/services/capability-packages/capability-route-registration.service.ts`) calls `app.inject()`, which arrives from `127.0.0.1`. It adds only the package's internal-route token (`x-marinara-internal-route`). The global `androidLocalAuthHook` runs before the route-level `onRequest` that honors that token. It sees a loopback request with no session cookie and no `x-marinara-android-secret`, so it returns 401. Callers (Marinara-Agents `origin/staging` 486f3667): `packages/noodle/.../noodle-refresh-scheduler.service.ts:139` and `packages/slurp/.../slurp-refresh-scheduler.service.ts:140`, both through `runInternalRoute({ method: "POST", url: "/api/<id>/refresh", ... })`. ## Reproduction A scratch Fastify app with the real `androidLocalAuthHook` and the real `registerCapabilityPrivilegedRoutes` registered a fake `noodle` package with `POST /refresh`. With `MARINARA_ANDROID_SECRET` set to 64 hex characters, `runCapabilityInternalRoute(app, "noodle", { method: "POST", url: "/api/noodle/refresh" })` returned 401. With the variable unset, it returned 200. Desktop, Docker, LAN and manual Termux installs don't set `MARINARA_ANDROID_SECRET`, so they are not affected. ## Fix needs a choice 1. Add `androidLocalAuthInjectHeaders()` (added in #7484) to the inject in `runCapabilityInternalRoute`. This is a one-line fix, but it hands the install secret to the package's route handler in `request.headers`. Packages already run in-process, but a package that logs request headers would then write the secret to its logs. 2. Let `androidLocalAuthHook` accept a request that carries a valid, active internal-route token for that URL's package prefix. The secret never reaches package code, and the bypass stays limited to the package's own routes, which `runInternalRoute` already allows. Option 2 looks safer. Either fix needs a regression in `scripts/regressions/android-local-auth.regression.ts` that runs `runCapabilityInternalRoute` with the Android secret set. Engine-owned: this is the capability route API and local auth, not package code. No Marinara-Agents change is needed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4178
No description provided.