Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

feat(auth): allow explicit plaintext human login

AkitaOnRailsa900c73298c0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8876c71..4e7df88b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,12 @@ version in [`docs/changelog/`](docs/changelog/):
## [Unreleased]
### Added
+- Added an explicit `serve --allow-insecure-human-auth` (or
+ `AI_MEMORY_ALLOW_INSECURE_HUMAN_AUTH=true`) escape hatch for operators who
+ knowingly run password login over plain HTTP on a private LAN.
+ It is off by default, does not bypass the separate unauthenticated-exposure
+ guard, and prints an unconditional warning that passwords, API credentials,
+ session cookies, and memory data cross the network unencrypted. (#1383)
- Added first-party Cline CLI lifecycle and MCP support. `install-hooks
--agent cline --apply` writes Cline's nine supported event files globally or
per project, refuses user-owned and symlinked targets, and keeps embedded
diff --git a/README.md b/README.md
index 9bbe482a..47767051 100644
--- a/README.md
+++ b/README.md
@@ -637,6 +637,10 @@ a reverse proxy. Capture is sanitized at a typed privacy boundary before
anything is stored, and per-repository `[capture]` rules can exclude
paths or invert to allowlist mode. A repository can also route its capture
to a different server than the one the hooks were installed against.
+Human login beyond loopback requires an HTTPS posture by default. Operators
+who explicitly accept plaintext passwords, cookies, credentials, and memory
+traffic on a private LAN can opt in with `serve --allow-insecure-human-auth`;
+the server never enables that exception implicitly.
The full model is in [`docs/security.md`](docs/security.md),
[`docs/users.md`](docs/users.md), and
diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rs
index f7b09744..bd6c0273 100644
--- a/crates/ai-memory-cli/src/cli.rs
+++ b/crates/ai-memory-cli/src/cli.rs
@@ -3456,6 +3456,12 @@ pub struct ServeArgs {
/// or a loopback bind instead.
#[arg(long)]
pub allow_insecure_no_auth: bool,
+ /// DANGEROUS: allow human login over plain HTTP on a non-loopback bind.
+ ///
+ /// HTTP-only. Passwords, session cookies, API credentials, and memory data
+ /// can be read or modified by anyone able to intercept the connection.
+ #[arg(long, env = "AI_MEMORY_ALLOW_INSECURE_HUMAN_AUTH")]
+ pub allow_insecure_human_auth: bool,
/// Skip the filesystem watcher; useful for transient debugging.
#[arg(long)]
pub no_watcher: bool,
@@ -3797,19 +3803,35 @@ mod tests {
}
#[test]
- fn serve_parses_insecure_no_auth_override() {
+ fn serve_parses_insecure_transport_overrides() {
let parsed = Cli::try_parse_from([
"ai-memory",
"serve",
"--transport",
"http",
"--allow-insecure-no-auth",
+ "--allow-insecure-human-auth",
])
.expect("serve override parses");
let Command::Serve(args) = parsed.command else {
panic!("expected serve command");
};
assert!(args.allow_insecure_no_auth);
+ assert!(args.allow_insecure_human_auth);
+
+ let command = Cli::command();
+ let serve = command
+ .get_subcommands()
+ .find(|subcommand| subcommand.get_name() == "serve")
+ .expect("serve subcommand exists");
+ let human_override = serve
+ .get_arguments()
+ .find(|argument| argument.get_id() == "allow_insecure_human_auth")
+ .expect("human-auth override exists");
+ assert_eq!(
+ human_override.get_env(),
+ Some(std::ffi::OsStr::new("AI_MEMORY_ALLOW_INSECURE_HUMAN_AUTH"))
+ );
}
#[test]
diff --git a/crates/ai-memory-cli/src/commands/serve.rs b/crates/ai-memory-cli/src/commands/serve.rs
index ee86d6df..bf1c3f28 100644
--- a/crates/ai-memory-cli/src/commands/serve.rs
+++ b/crates/ai-memory-cli/src/commands/serve.rs
@@ -545,6 +545,9 @@ enum HttpExposure {
/// Unauthenticated on a non-loopback address, allowed because the
/// operator passed `--allow-insecure-no-auth`.
InsecureByOverride,
+ /// Human passwords and cookies are crossing a non-loopback plain-HTTP
+ /// connection because the operator accepted that transport risk.
+ InsecureHumanAuthByOverride,
/// Unauthenticated on a non-loopback address inside a container, where
/// the bind address is not evidence either way. See
/// [`validate_http_exposure`].
@@ -585,16 +588,21 @@ fn validate_http_exposure(
human_mode: bool,
secure_cookie: bool,
allow_insecure_no_auth: bool,
+ allow_insecure_human_auth: bool,
containerized: bool,
) -> Result<HttpExposure> {
if local_addr.ip().is_loopback() {
return Ok(HttpExposure::Safe);
}
if human_mode && !secure_cookie {
+ if auth_enabled && allow_insecure_human_auth {
+ return Ok(HttpExposure::InsecureHumanAuthByOverride);
+ }
anyhow::bail!(
"refusing human authentication on non-loopback plain HTTP address {local_addr}: \
passwords and session cookies require [auth].secure_cookie=true behind a trusted \
- HTTPS reverse proxy. Non-Secure human cookies are allowed only on loopback."
+ HTTPS reverse proxy. Non-Secure human cookies are allowed only on loopback unless \
+ --allow-insecure-human-auth explicitly accepts plaintext transport."
);
}
if auth_enabled {
@@ -629,6 +637,12 @@ fn exposure_banner(exposure: HttpExposure, local_addr: SocketAddr) -> Option<Str
--allow-insecure-no-auth was supplied. Anyone who can reach this address can call \
destructive MCP tools."
)),
+ HttpExposure::InsecureHumanAuthByOverride => Some(format!(
+ "WARNING: ai-memory is serving HUMAN AUTHENTICATION on plain HTTP at {local_addr} \
+ because --allow-insecure-human-auth was supplied. Passwords, API credentials, \
+ session cookies, and memory data are unencrypted; a network peer can steal or \
+ modify them. Use this only on a network whose plaintext risk you explicitly accept."
+ )),
HttpExposure::UndeterminedInContainer => Some(format!(
"WARNING: ai-memory is listening on {local_addr} with NO AUTHENTICATION. Inside a \
container the bind address cannot show whether this port reaches the network - the \
@@ -1931,6 +1945,7 @@ pub async fn run(config: &Config, args: ServeArgs) -> Result<()> {
human_mode,
config.auth.secure_cookie,
args.allow_insecure_no_auth,
+ args.allow_insecure_human_auth,
running_in_container(),
)?;
info!(
@@ -1951,6 +1966,13 @@ pub async fn run(config: &Config, args: ServeArgs) -> Result<()> {
--allow-insecure-no-auth was supplied — anyone on the network can call \
destructive MCP tools"
);
+ } else if exposure == HttpExposure::InsecureHumanAuthByOverride {
+ tracing::warn!(
+ %local_addr,
+ "starting human authentication on non-loopback plain HTTP because \
+ --allow-insecure-human-auth was supplied — passwords, API credentials, \
+ session cookies, and memory data cross the network unencrypted"
+ );
} else if exposure == HttpExposure::UndeterminedInContainer {
tracing::warn!(
%local_addr,
@@ -3818,6 +3840,7 @@ mod tests {
false,
allow_override,
false,
+ false,
)
.is_ok(),
allowed,
@@ -3831,16 +3854,25 @@ mod tests {
#[test]
fn human_auth_non_loopback_requires_secure_cookie_posture() {
let remote: SocketAddr = "192.168.1.90:49374".parse().unwrap();
- assert!(validate_http_exposure(remote, true, true, false, false, false).is_err());
- assert!(validate_http_exposure(remote, true, true, false, true, true).is_err());
+ assert!(validate_http_exposure(remote, true, true, false, false, false, false).is_err());
+ assert!(validate_http_exposure(remote, true, true, false, true, false, true).is_err());
assert_eq!(
- validate_http_exposure(remote, true, true, true, false, false).unwrap(),
+ validate_http_exposure(remote, true, true, true, false, false, false).unwrap(),
HttpExposure::Safe
);
+ assert_eq!(
+ validate_http_exposure(remote, true, true, false, false, true, false).unwrap(),
+ HttpExposure::InsecureHumanAuthByOverride
+ );
+
+ // The human-auth override must not become a second way to expose a
+ // server with no authentication at all.
+ assert!(validate_http_exposure(remote, false, false, false, false, true, false).is_err());
+ assert!(validate_http_exposure(remote, false, true, false, false, true, false).is_err());
let loopback: SocketAddr = "127.0.0.1:49374".parse().unwrap();
assert_eq!(
- validate_http_exposure(loopback, true, true, false, false, false).unwrap(),
+ validate_http_exposure(loopback, true, true, false, false, true, false).unwrap(),
HttpExposure::Safe
);
}
@@ -3861,6 +3893,12 @@ mod tests {
assert!(override_banner.contains("0.0.0.0:49374"));
assert!(override_banner.contains("--allow-insecure-no-auth"));
+ let human_banner = exposure_banner(HttpExposure::InsecureHumanAuthByOverride, addr)
+ .expect("an insecure human-auth override must be announced");
+ assert!(human_banner.contains("HUMAN AUTHENTICATION"));
+ assert!(human_banner.contains("--allow-insecure-human-auth"));
+ assert!(human_banner.contains("session cookies"));
+
let container_banner = exposure_banner(HttpExposure::UndeterminedInContainer, addr)
.expect("an unauthenticated container bind must be announced");
assert!(container_banner.contains("NO AUTHENTICATION"));
@@ -3877,13 +3915,13 @@ mod tests {
fn the_quick_start_container_bind_is_announced_not_refused() {
let quick_start: SocketAddr = "0.0.0.0:49374".parse().expect("valid test address");
- let exposure = validate_http_exposure(quick_start, false, false, false, false, true)
+ let exposure = validate_http_exposure(quick_start, false, false, false, false, false, true)
.expect("must not refuse");
assert_eq!(exposure, HttpExposure::UndeterminedInContainer);
assert!(exposure_banner(exposure, quick_start).is_some());
// With a token configured there is nothing to announce.
- let authed = validate_http_exposure(quick_start, true, false, false, false, true)
+ let authed = validate_http_exposure(quick_start, true, false, false, false, false, true)
.expect("auth is fine");
assert_eq!(exposure_banner(authed, quick_start), None);
}
@@ -3898,19 +3936,21 @@ mod tests {
// The exact Quick Start shape: no token, no override, in a container.
assert_eq!(
- validate_http_exposure(quick_start, false, false, false, false, true)
+ validate_http_exposure(quick_start, false, false, false, false, false, true)
.expect("must not refuse"),
HttpExposure::UndeterminedInContainer,
);
// Identical inputs on a host still refuse — the carve-out is scoped
// to the container case and does not soften the host rule.
- assert!(validate_http_exposure(quick_start, false, false, false, false, false).is_err());
+ assert!(
+ validate_http_exposure(quick_start, false, false, false, false, false, false).is_err()
+ );
// A container is not a blanket downgrade: with machine auth configured
// the verdict is Safe, so the operator gets no spurious warning.
assert_eq!(
- validate_http_exposure(quick_start, true, false, false, false, true)
+ validate_http_exposure(quick_start, true, false, false, false, false, true)
.expect("auth is fine"),
HttpExposure::Safe,
);
@@ -3918,7 +3958,7 @@ mod tests {
// An explicit override still reports as an override, not as the
// container case, so the startup log keeps naming the real reason.
assert_eq!(
- validate_http_exposure(quick_start, false, false, false, true, true)
+ validate_http_exposure(quick_start, false, false, false, true, false, true)
.expect("override is fine"),
HttpExposure::InsecureByOverride,
);
@@ -3926,7 +3966,7 @@ mod tests {
// Loopback inside a container is plain Safe.
let loopback: SocketAddr = "127.0.0.1:49374".parse().expect("valid test address");
assert_eq!(
- validate_http_exposure(loopback, false, false, false, false, true)
+ validate_http_exposure(loopback, false, false, false, false, false, true)
.expect("loopback is fine"),
HttpExposure::Safe,
);
diff --git a/docs/https-via-proxy.md b/docs/https-via-proxy.md
index 2f9234ed..45b26cca 100644
--- a/docs/https-via-proxy.md
+++ b/docs/https-via-proxy.md
@@ -37,8 +37,12 @@ Bearer deployments may still bind authenticated plain HTTP and receive a loud
warning because those credentials remain sniffable. Human authentication is
stricter: a non-loopback listener refuses startup unless
`AI_MEMORY_AUTH__SECURE_COOKIE=true`, which is the operator's explicit signal
-that a trusted HTTPS proxy owns the browser-facing edge. Non-Secure human
-cookies are supported only on an actual loopback listener.
+that a trusted HTTPS proxy owns the browser-facing edge. The only exception is
+the explicit `serve --allow-insecure-human-auth` escape hatch (environment
+`AI_MEMORY_ALLOW_INSECURE_HUMAN_AUTH=true`) for an operator who knowingly
+accepts plaintext passwords, credentials, session cookies, and memory data on
+a private LAN. The option is disabled by default, does not bypass the
+unauthenticated-exposure guard, and prints an unconditional warning.
## Pick a path
diff --git a/docs/install.md b/docs/install.md
index 68988b5e..649afb5b 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -3519,6 +3519,15 @@ CIDRs in `AI_MEMORY_AUTH__TRUSTED_PROXY_CIDRS` may supply `X-Forwarded-For`
for login rate limits; untrusted peers' XFF is ignored. Behind HTTPS, set
`AI_MEMORY_AUTH__SECURE_COOKIE=true` as noted above.
+An operator who intentionally accepts unencrypted human authentication on a
+private LAN can instead pass `serve --allow-insecure-human-auth` (or set
+`AI_MEMORY_ALLOW_INSECURE_HUMAN_AUTH=true`, including in Docker). The option is
+off by default and does not make plaintext transport safe: passwords, Bearer
+and API credentials, session cookies, and memory data can all be intercepted
+or modified. It bypasses only the non-loopback human-cookie posture check; a
+server without authentication still needs the separate
+`--allow-insecure-no-auth` override.
+
## Operating without auth
For local-only / single-machine deploys you can skip the bearer
diff --git a/docs/security-boundaries.md b/docs/security-boundaries.md
index c20e83ac..5d2ad8bf 100644
--- a/docs/security-boundaries.md
+++ b/docs/security-boundaries.md
@@ -133,6 +133,7 @@ means the boundary is not built yet.
| 25 | Opt-in consolidation residue cannot turn captured observation text into prompt structure or a direct wiki write (#1215) | `ai-memory-consolidate/src/projection.rs` `render_verbatim_residue` excludes routing text, passes prompt-shaped observations through `profile::user_written`, strips tool metadata, mines bounded literal classes, rejects every Unicode/ASCII line end, and renders one indented token per line under an explicit untrusted-data header; total, group, token and observation-pruning caps bound work and disclosure. `Consolidator` includes the block only when `[consolidation] verbatim_residue` is true and still accepts only the existing JSON-schema structured response through the normal wiki-write boundary | projection `residue_keeps_hostile_lines_indented_and_never_forges_observation_headers` (instruction-shaped error plus forged header and mixed line endings; legitimate path control), `residue_refuses_harness_prompts_but_keeps_the_same_user_written_error` (harness block refused, user-written control admitted), `residue_stays_inside_projection_and_group_budgets_without_clipping`, `residue_off_is_byte_identical_and_on_is_inert_without_missing_text`; integration `verbatim_residue_consolidation::residue_changes_only_the_provider_request_not_the_stored_page` captures both requests and proves the fixed structured response produces the same page | STRONG for prompt framing and the direct-write boundary; enabling the option deliberately sends a wider bounded subset of already-sanitized capture to the configured provider |
| 26 | Cross-harness native-history continuation stays checkout-scoped and client-local | `ai-memory-store/src/workstream.rs` `prepare_run` selects the newest current native session only when its harness differs from the destination and pins that typed identity on the run before destination linking can change recency; `ai-memory-cli/src/commands/run.rs` validates the returned `NativeSessionIdentity`, resolves only known adapter flavors, requires `native_session_in_checkout`, exports through the bounded read-only adapter, and writes an untrusted-history dossier to a private temporary directory exposed only to the child as `AI_MEMORY_PREVIOUS_SESSION_HISTORY`; the server wire type deliberately has no path/content field and same-harness launches select no source; `ai-memory-hooks/src/router.rs` keeps the server-authored resume directive outside the untrusted-history fence while fencing the transcript evidence itself, and `ai-memory-core/src/routing_snippet.rs` gives installed project instructions the same wrapper-variable-gated fallback | Core `prepare_response_carries_only_previous_native_identity`, `older_prepare_response_defaults_to_no_adoption`, and `snippets_route_managed_continue_to_the_previous_native_history`; store `managed_adoption_stops_after_any_harness_links_the_workstream` (switch control, destination-link recency cannot replace the pinned source, same-harness refusal); hooks `managed_context_points_at_local_history_on_a_harness_switch` (no session id rendered, directive precedes the untrusted fence); CLI `previous_session_history_is_private_local_and_checkout_scoped` (legitimate control, foreign checkout refused, private local file removed with its owner) | STRONG for checkout isolation, prompt-boundary placement, and server path/content privacy. The dossier is a bounded visible-history projection, not raw hidden reasoning; if the source store is absent, remote, unreadable, or over bounds, the child receives only the portable ledger and handoff |
+| 27 | Plain-HTTP human authentication stays fail-closed beyond loopback unless the operator supplies the dedicated dangerous override (#1383) | `ai-memory-cli/src/cli.rs` exposes `serve --allow-insecure-human-auth` separately from `--allow-insecure-no-auth`; `serve.rs` `validate_http_exposure` accepts it only when authentication and human mode are both active and the listener is non-loopback with a Non-Secure cookie, while the ordinary unauthenticated guard still runs otherwise. `HttpExposure::InsecureHumanAuthByOverride` gives that path its own unconditional stderr banner and structured warning, naming passwords, API credentials, session cookies, and memory data as plaintext. The default remains refusal, and `secure_cookie=true` or loopback remains the safe path | `serve.rs` `human_auth_non_loopback_requires_secure_cookie_posture` (default refusal, the no-auth override cannot substitute, the dedicated override succeeds, and that override cannot expose a server with no authentication even under inconsistent human-mode input; secure-cookie and loopback controls), `every_unsafe_exposure_produces_an_operator_banner` (the dedicated banner names the flag and session-cookie risk), and `cli.rs` `serve_parses_insecure_transport_overrides` (both dangerous flags remain distinct) | STRONG for the startup boundary. This is an explicit operator acceptance of transport risk, not encryption; authorization, CSRF, rate limits, Host validation, and the unauthenticated exposure refusal are unchanged |
### IBM Bob evidence
diff --git a/docs/security.md b/docs/security.md
index 634575dd..bc9d7a0c 100644
--- a/docs/security.md
+++ b/docs/security.md
@@ -71,6 +71,30 @@ HTTPS-only. Close or redirect direct HTTP access to that hostname.
Non-loopback binds should also set `AI_MEMORY_ALLOWED_HOSTS` to guard against
DNS rebinding.
+For a private LAN where the operator deliberately accepts plaintext transport,
+`serve --allow-insecure-human-auth` (environment
+`AI_MEMORY_ALLOW_INSECURE_HUMAN_AUTH=true`) permits a non-loopback listener
+with a Non-Secure human session cookie. This exception is disabled by default
+and prints an unconditional startup warning. It does not weaken password
+checks, session or API-key authorization, CSRF, rate limits, the Host allowlist,
+or the separate unauthenticated-exposure guard. It also provides no encryption:
+any peer able to observe or alter LAN traffic can steal passwords, Bearer/API
+credentials, session cookies, and memory data. Prefer the HTTPS proxy path.
+The option changes no stored user, password, session, or API-key state; removing
+it restores the startup refusal.
+
+For the official Docker image, the environment form avoids replacing its
+default `serve` command:
+
+```bash
+docker run -d --name ai-memory \
+ -p 192.168.1.100:49374:49374 \
+ -v ai-memory-data:/data \
+ -e AI_MEMORY_ALLOW_INSECURE_HUMAN_AUTH=true \
+ -e AI_MEMORY_ALLOWED_HOSTS="192.168.1.100,localhost,127.0.0.1" \
+ akitaonrails/ai-memory:latest
+```
+
With no token (the loopback default), a web page open in your browser can
still address `127.0.0.1:49374`. The server refuses those requests on the
machine and admin routes: a request the browser marks as cross-site
diff --git a/docs/users.md b/docs/users.md
index b24f5b44..a1eb504c 100644
--- a/docs/users.md
+++ b/docs/users.md
@@ -137,10 +137,13 @@ root_subject = "<root-subject>"
root bearer is absent.
- Only set it when the server is reachable *only* through that proxy.
- `secure_cookie` is independent of proxy identity. Human auth requires it on
- every non-loopback listener; ai-memory treats it as the explicit signal that
- a trusted reverse proxy terminates HTTPS for `/web` and never trusts
- forwarded protocol headers to infer that fact. Direct HTTP browsers will not
- send a Secure cookie.
+ every non-loopback listener by default; ai-memory treats it as the explicit
+ signal that a trusted reverse proxy terminates HTTPS for `/web` and never
+ trusts forwarded protocol headers to infer that fact. Direct HTTP browsers
+ will not send a Secure cookie. `serve --allow-insecure-human-auth` (or
+ `AI_MEMORY_ALLOW_INSECURE_HUMAN_AUTH=true`) is the explicit, dangerous
+ exception for a private LAN whose operator accepts that passwords,
+ credentials, cookies, and memory data travel unencrypted.
- **The proxy MUST strip client-supplied `X-Memory-Actor-*` headers before
setting its own.** Use a directive that *replaces* the header rather than
appending to it (nginx `proxy_set_header`, Traefik `customRequestHeaders`).