Skip to content

fix(cloud): drive IAM Identity Center device-login under a pty (kiro-cli #4243) - #9877

Closed
DaxterXS wants to merge 4 commits into
kirodotdev:mainfrom
DaxterXS:fix/idc-device-login-stdin-feed
Closed

DaxterXS wants to merge 4 commits into
kirodotdev:mainfrom
DaxterXS:fix/idc-device-login-stdin-feed

Conversation

@DaxterXS

@DaxterXS DaxterXS commented Sep 10, 2026 •

Copy link
Copy Markdown

Problem / Motivation

kirocrew cloud launch / kirocrew cloud login can sign the on-box kiro-cli into an enterprise IAM Identity Center by passing --identity-provider / --license pro / --idp-region to kiro-cli login.

But several kiro-cli builds still show the interactive prompts Enter Start URL / Enter Region (only --license is honored non-interactively) — kiro-cli issue #4243. Those prompts are a TUI widget that reads the controlling TTY, not stdin.

The launcher runs kiro-cli login in the background over SSM with no tty and stdin from /dev/null. The prompts never render or submit, no device-code URL is printed, the capture loop times out, and start_device_login then falls through to the social/callback-port path — a misleading "Google/GitHub sign-in needs a forwarded callback port" message for what is actually an Identity Center login. Automated step-5 sign-in never completes.

Reproduced on a live deployment (Amazon Linux 2023, arm64). Under a pty with the pre-filled prompts submitted, the device code prints with no human typing:

printf '\n\n\n' | script -qec "kiro-cli login --use-device-flow --license pro --identity-provider https://<org>.awsapps.com/start/ --region eu-central-1" /tmp/idc.log
# Enter Start URL · https://<org>.awsapps.com/start/
# Enter Region    · eu-central-1
# Open this URL: https://<org>.awsapps.com/start/#/device?user_code=XXXX-XXXX

Feeding the answers on stdin (a file or pipe redirect) does not work — the widget reads the tty, not stdin. A bare pty with no input parks at the first prompt. It takes a pty and the newlines fed into it.

Why it matters

Every enterprise / IAM Identity Center user on an affected kiro-cli build is blocked: the one-command kirocrew cloud launch that should end with a working box instead leaves them signed out, the dashboard errors on every new chat, and the on-screen guidance points at the wrong problem (a social-login callback port). The only workaround today is to SSM onto the box and run kiro-cli login by hand as ec2-user, answering the prompts — which defeats the automated launcher and is not discoverable.

What changed

Observed symptom: automated IdC sign-in stalls with no device code, then reports a bogus callback-port error.
Root cause: (1) the prompts are a TUI widget bound to the controlling tty, but the background login has no tty and stdin </dev/null, so nothing renders or submits them; (2) the no-URL branch of start_device_login unconditionally falls through to the social/callback flow, which does not exist for Identity Center.

Change, in src/kiro_crew/cloud/login.py:

  • _device_login_command — on the enterprise path (identity_provider set), run kiro-cli login under a pseudo-tty via util-linux script and feed newlines into that pty to submit the flag-prefilled prompts. The login command's own stdout/stderr is redirected to the capture log; script's typescript goes to /dev/null so the log holds the device-code URL, not the pty transcript (whose echoed "Enter Start URL · https://…" line would otherwise be captured instead). KIRO is exported so the script/sh -c subshell resolves the binary. The Builder ID / social path is byte-for-byte unchanged (no pty, stdin </dev/null).
  • start_device_login — on the Identity Center path, return an honest device-code timeout instead of falling through to _start_callback_login.

Considered and rejected: feeding the answers on stdin (a file redirect or a printf | pipe / bash process substitution) — proven on the box not to reach the tty-bound widget; only widening the capture window — doesn't help when the prompt never submits; a bare pty with no fed input — parks at the first prompt.

Tests

test/test_cloud_login.py adds TestDeviceLoginIdentityCenter and TestStartDeviceLoginFallback:

  • Builder ID path unchanged — plain --use-device-flow, no pty, stdin </dev/null, no enterprise flags.
  • IdC path uses a pty + fed newlines — flags present, command runs under script, printf feeds the newlines, KIRO is exported, login output goes to the log.
  • Injection safety — a hostile start URL containing shell metacharacters is fully shlex.quoted and cannot escape into the remote shell.
  • Resume path — _resume_login_command threads the same pty behavior; the default variant does not.
  • Honest fallback — an IdC device-code timeout does not invoke _start_callback_login and returns an "Identity Center" error.

Manual verification

Verified end-to-end on a real deployment (Amazon Linux 2023 arm64, IAM Identity Center start URL, eu-central-1): the invocation the fix generates emits a …#/device?user_code=XXXX-XXXX URL with no human at the box; the prior </dev/null and stdin-redirect attempts produced only the un-submitted prompt line, which pinned the tty-vs-stdin root cause.

Note: the project's pytest suite was not run in my local environment (no dev venv available); the added tests were exercised with an equivalent standalone runner. CI on this PR runs the real suite.

Related Issues

Upstream root cause: kirodotdev/Kiro#4243 (kiro-cli's Identity Center prompts appear despite the flags and read the tty).

Pattern harvest

Rule candidate: review-prompt
Pattern: automating a CLI that uses an interactive TUI prompt (dialoguer/inquire-style) requires a pseudo-tty, not stdin redirection — those widgets read /dev/tty, so </dev/null or a piped/file stdin never reaches them; allocate a pty (util-linux script) and feed the keystrokes into it. Also: a "no result" branch that falls through to an unrelated recovery path (here, social-login callback) should be gated on the mode that actually supports it, so failures report the true cause.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — N/A, no user-facing docs change
  • No secrets, credentials, or internal references in the diff

@DaxterXS
DaxterXS requested review from a team and CrysisDeu September 10, 2026 08:03
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@dwu96

dwu96 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🔴 BLOCK (blocking)

Design-level review of aad5aee2fa7aed6effd79f618e3eb5413aed7593 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: BLOCK

Stale duplicate: main already fixed kiro-cli #4243 (#9840); merging this reverts the landed pty driver, dir guard, and pinned-target gating, breaking every device login.

Blockers

Superseded fix whose diff now reverts three landed decisions and breaks the login path.
The description's premise — "the no-URL branch of start_device_login unconditionally falls through" — is false at this base: resolved.is_identity_center already blocks fall-through ("Pinned: stay on this identity. Report, do not degrade."), and #9840's driver already "gives it a pty and presses Enter on each prefilled prompt" (the identical root cause this PR names). Applied today, the diff (a) replaces {_login_dir_guard()} with export KIRO, deleting the only definition of KC_LOGIN_DIR — so _LOGIN_LOG_PATH ("$KC_LOGIN_DIR/kiro-login.log") expands to /kiro-login.log, the capture loop never sees a log, and every device login (Builder ID included) times out, while also removing the #11497/#11825 symlink/owner check the retained "owner-checked above" comment still claims; (b) rewrites start_device_login to read identity_provider/license_/idp_region, names no longer in that function's scope (signature is target: Optional[KiroLoginTarget] since #11390) — NameError on the IdC path, and the new tests pass kwargs the function doesn't accept; (c) rewrites the TestIdentityProviderFlags pins around a script -qec shape as if the driver pin were a gap, when it was #9840's deliberate hardening (unpredictable mktemp path, _DRIVER_SETUP_FAILED_SENTINEL reporting) — none of which the description acknowledges removing.
Fix: rebase onto current main; if the bug still reproduces there, file that as a new PR against the driver. If script -qec is proposed as a simplification of the driver, it must be its own PR that keeps _login_dir_guard(), the setup-failure reporting, and resolved.is_identity_center gating.
Clears when: the PR is closed as superseded by #9840, or rebased onto current main with _login_dir_guard(), the pinned-target (KiroLoginTarget) gating, and failure reporting intact, and a reproduction on that base justifying any remaining change.

[DESIGN-REVIEWED] aad5aee

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🔴 BLOCK

Premise-level review of aad5aee2fa7aed6effd79f618e3eb5413aed7593 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: BLOCK

Both fixes already exist on base: the Python pty driver and the pinned no-fallback IdC branch — this diff deletes them and re-ships a second spelling.

Not justified as shipped

  • Item 1 — duplicate of src/kiro_crew/cloud/login.py:98: _LOGIN_PTY_DRIVER + the mktemp staging block (login.py:794-827) already runs the IdC login under a pty, submits the prefilled prompts, and filters the echoed start URL; grep _LOGIN_PTY_DRIVER = 2 src sites + a real-pty test executing it (test_cloud_login_target.py:440-476).
    Subtraction: delete the diff; rebase the fork onto current main, which already carries this fix.
    Clears when: a defect in the existing driver is reproduced against current main, or the PR rebases and becomes empty.
  • Item 2 — framing contradicted by diff: description claims the no-URL branch "unconditionally falls through to the social/callback flow", but the diff deletes base's branch whose own comment reads "Pinned: stay on this identity. Report, do not degrade." (login.py:492), pinned by assert not fell_back (test_cloud_login_target.py:376-388) — never mentioned in the description.
    Clears when: the deletion is dropped, or evidence the pinned branch misbehaves on current main.
  • Item 3 — undeclared: the driver-staging failure report (_DRIVER_SETUP_FAILED_SENTINEL branch, login.py:494) is deleted, leaving the sentinel with 0 src consumers (grep: definition + 2 deleted sites; 3 base tests pin it).
  • Item 4 — undeclared: {_login_dir_guard()} is replaced by export KIRO, deleting the documented symlink guard and leaving $KC_LOGIN_DIR — every log/pid path in the script — undefined.
    Clears when: the guard deletion is dropped.
  • Item 5 — undeclared: pty now applies only when identity_provider is set; base applies it for any of the three enterprise flags.
  • Item 6 — rides along: export KIRO, needed only by the new spelling.
  • Item 7 — rides along: base quoting tests rewritten to the script -qec spelling.

What this change ships

Inventory (7 items) — 0 justified

Intent: make automated IAM Identity Center sign-in on a cloud launch complete without a human at the box — a FIX.

  1. IdC login driven by util-linux script pty, replacing the existing Python pty driver — duplicate of src/kiro_crew/cloud/login.py:98
  2. IdC timeout keeps its no-callback behavior but with a rewritten error message — duplicate of src/kiro_crew/cloud/login.py:492
  3. Driver-staging failure no longer reported by name — undeclared, zero consumers left for the sentinel
  4. Private login-dir guard removed from the device-login script — undeclared
  5. Pty now only for identity_provider, not license/region-only logins — undeclared
  6. KIRO exported in the login script — rides along
  7. Existing flag-quoting tests rewritten around the new pty spelling — rides along

Blockers

  • Duplicates an existing mechanism. The zero option costs nobody anything: base already runs the pinned IdC login under a pty that presses Enter on each prefilled prompt (_LOGIN_PTY_DRIVER, login.py:98-137, staged at login.py:794-827) and already refuses the social/callback fallback (login.py:492-505). Grep _LOGIN_PTY_DRIVER: 2 src sites, 1 test running it end-to-end under a real pty. The new code even references identity_provider/license_/idp_region names absent from base start_device_login's target-based signature — the branch was authored against a pre-KiroLoginTarget file. Subtraction: close or rebase; the diff should vanish against current main.
    Clears when: rebased onto main with a remaining, reproduced defect in the existing driver — or the PR closes.
  • Framing contradicted by the diff: two pins deleted unmentioned. "the no-URL branch of start_device_login unconditionally falls through to the social/callback flow" vs the deleted pin "Pinned: stay on this identity. Report, do not degrade." (login.py:493) and its test assert not fell_back; likewise the deleted mktemp/_login_dir_guard protections whose comments state the symlink threat they close, replaced silently.
    Clears when: the description's claimed defects are shown to exist on current main.

[FIRST-PRINCIPLES-REVIEWED] aad5aee

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — 🔴 changes requested (blocking)

Reviewed aad5aee2fa7aed6effd79f618e3eb5413aed7593 via the fork AI-review pipeline; updated in place on each push.

1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

BLOCKING -- src/kiro_crew/cloud/login.py:843 -- private login-directory guard was removed
export KIRO # so the pty/subshell on the enterprise path can resolve the binary
Logged-out instance -> start_device_login -> unset KC_LOGIN_DIR resolves files under / -> ec2-user cannot create the log/PID, so sign-in produces no device code.
Anchor: residual/guard-removal
Fix: Restore {_login_dir_guard()} before exporting KIRO and touching login paths.
[BLOCK-MERGE] aad5aee
[GPT-REVIEWED] aad5aee

Adjudication (Opus 5) — is blocking on each finding proportionate?

F1 — src/kiro_crew/cloud/login.py:843 (new) / :841 (base)

Harm rung: UNBOUNDED as fenced — the removed snippet is the sole definition of the private, symlink-refusing, owner-checked 0700 directory that the device-code log/PID/FIFO are written into (login.py:155-192), and it is also the sole assignment of KC_LOGIN_DIR, which every path constant interpolates (login.py:56-58).

Conditions confirmed: the guard is spliced by every other remote script that touches those paths (login.py:664, :753, :953, :992, :1022) but the diff replaces it with export KIRO in _device_login_command only (patch line 134); that script has set +e and no set -u (login.py:839), so the unset variable silently degrades rm -f, the launch redirect, echo $! >, the capture grep and the final cat (login.py:843-860) to root-owned /-rooted paths, and the umask 077 comment at login.py:844-847 now cites an owner check that is no longer emitted. Recovery path: none — the capture loop simply times out and, on the same PR's new branch, returns a hand-written "did not produce a device code in time" string (patch lines 27-35), which is precisely a silent substitution of an honest-looking message for a broken invariant.

Rarity: none. This is not an extreme condition combination — it is the only path _device_login_command has, so every Identity Center and Builder ID device login on a logged-out instance runs without the guard. No FLAG record can be completed.

[ADJUDICATION] aad5aee2fa7aed6effd79f618e3eb5413aed7593 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] aad5aee2fa7aed6effd79f618e3eb5413aed7593

[ADJUDICATION-FENCED] aad5aee2fa7aed6effd79f618e3eb5413aed7593 fenced=1 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/cloud/login.py:843 -- The removed snippet is both the only assignment of `KC_LOGIN_DIR` and the only symlink/ownership/0700 check protecting the device-code log, and its absence is on the default path of every device login, not a rare condition combination.
[GPT-ADJUDICATED-FENCED] aad5aee2fa7aed6effd79f618e3eb5413aed7593

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — 🔴 changes requested (blocking)

Reviewed aad5aee2fa7aed6effd79f618e3eb5413aed7593 via the fork AI-review pipeline; updated in place on each push.

BLOCKING — start_device_login raises NameError on every device login that fails to capture a URL: it reads three names that are not in its scope.

[BLOCK-MERGE] aad5aee

BLOCKING — src/kiro_crew/cloud/login.py:497

    if identity_provider:
        idc_region = idp_region or region
        ... f"--license {license_ or 'pro'} " f"--identity-provider {identity_provider} --region {idc_region}"

identity_provider, license_ and idp_region are parameters of _device_login_command/_resume_login_command only (login.py:767-769, 1015-1017) and are not module globals; start_device_login's signature (login.py:444-451) is unchanged by this diff → any sign-in whose capture yields no URL (prompt.actionable False at line 487) hits line 497 and raises NameError instead of returning a prompt — on the Builder ID path too, so the social-callback fallback at line 507 is now unreachable. The PR's own test_identity_center_timeout_does_not_use_callback passes these as kwargs, which is a TypeError against that signature.
Fix: branch on resolved.is_identity_center and build the message from resolved (resolved.recovery_command() / resolved.start_url / resolved.region), not from undefined names.

BLOCKING — src/kiro_crew/cloud/login.py:843

export KIRO  # so the pty/subshell on the enterprise path can resolve the binary

This replaces {_login_dir_guard()}, the only assignment of KC_LOGIN_DIR (login.py:171), while _LOGIN_LOG_PATH/_LOGIN_PID_PATH/_LOGIN_FIFO_PATH still expand $KC_LOGIN_DIR → any kirocrew cloud login runs the script as ec2-user (ssm._wrap_remote_command, ssm.py:663) with the variable unset, so >"/kiro-login.log" and echo $! > "/kiro-login.pid" fail with permission denied, kiro-cli never starts and the capture loop returns nothing; it also drops the ${HOME:?}, symlink-refusal, -O owner and 0700 checks that protect the file holding the device-code URL + code, which the surviving comment at line 846 still claims ("0700, owner-checked above"). test_cloud_login_paths.py::test_guard_precedes_first_path_use pins this for device_builder and device_idc.
Fix: keep {_login_dir_guard()} and put export KIRO on its own line beside it, not in place of it.

BLOCKING — src/kiro_crew/cloud/login.py:816

        inner = f'"$KIRO" login --use-device-flow{extra_flags} >"{_LOGIN_LOG_PATH}" 2>&1'

shlex.quote(inner) single-quotes the whole invocation, so the outer bash never expands $KC_LOGIN_DIR; script -qec <cmd> runs <cmd> in a child shell that inherits only exported variables, and _login_dir_guard() sets KC_LOGIN_DIR without export (login.py:171) → even after restoring the guard, the Identity Center login redirects to /kiro-login.log while the outer capture loop greps $HOME/.kirocrew/login/kiro-login.log, so the device code is never captured and the log lands outside the 0700 directory.
Fix: export KC_LOGIN_DIR alongside export KIRO, or build inner so the outer shell substitutes the path before shlex.quote.

[OPUS-REVIEWED] aad5aee

@DaxterXS
DaxterXS force-pushed the fix/idc-device-login-stdin-feed branch from 9259a31 to 5e85ca9 Compare September 10, 2026 08:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 10, 2026
@DaxterXS
DaxterXS force-pushed the fix/idc-device-login-stdin-feed branch from 5e85ca9 to 2378643 Compare September 10, 2026 09:19
@DaxterXS

Copy link
Copy Markdown
Author

Thanks for the reviews — pushed a revision (2378643) addressing the findings:

GPT 5.6 (log capture) — fixed. You're right: script -qec CMD LOGFILE writes the pty typescript to LOGFILE, whose header + echoed ✔ Enter Start URL · https://… line would be the first https:// the capture loop greps, returning the Start URL instead of the device code. The revision redirects the login command's own stdout/stderr to the log and sends script's typescript to /dev/null:
printf '\n\n\n' | script -qec '"$KIRO" login … >"$LOG" 2>&1' /dev/null. The log now holds the device-code URL, not the transcript.

First Principles (BLOCK) — subtractions applied.

  • Dropped the printf | feed in the no-script else branch and restored the base </dev/null + stdbuf invocation (the piped-stdin feed was dead surface, as the description's own evidence shows, and it silently dropped stdbuf). There's no longer a separate else branch that changes behavior — if script is absent the enterprise path simply can't submit the tty prompts, same as before this PR.
  • Reverted capture_attempts from max(…, 40) back to _DEVICE_LOGIN_CAPTURE_ATTEMPTS — the lag was asserted, not measured.

On the core BLOCK (all IdC logins routed through the pty, unverified on flag-honoring builds): with the log-capture fix, a build that honors the flags prints the device URL straight to the redirected log and the fed newlines are consumed by the pty with no prompt to answer — so the pty path is non-breaking there by construction, not by assumption. I can only test the affected build (Amazon Linux 2023 arm64, kiro-cli as shipped by the launcher's own bootstrap); I don't have a flag-honoring build to name. If a maintainer can confirm on one, I'll cite it; otherwise I'm happy to gate the pty strictly behind identity_provider (already the case) and note the build dependency.

Design Review (CONCERNS) — acknowledged.

  • The echoed-Start-URL-matches-passed-value check is a good hardening idea; I've left it out of this revision to keep the diff minimal but can add it (the loop already greps that log) if you'd prefer it in-scope.
  • Completed-sign-in (not just device-code emission) via the backgrounded path: honestly disclosed in Manual verification. I verified code emission unattended; the browser-approval → wait_until_logged_in flip I confirmed only via the foreground/manual login. I'd rather say that plainly than claim a full unattended run I haven't captured.

PR Hygiene / description bot: changed the heading to a literal ## What changed (kept the parenthetical as a subtitle).

Opus 4.8 found no blocking issues and confirmed the shlex-quoting survives the nested sh -c/script construction.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 10, 2026
@DaxterXS DaxterXS changed the title cloud: fix IAM Identity Center device-login stalling on kiro-cli #4243 fix(cloud): drive IAM Identity Center device-login under a pty (kiro-cli #4243) Sep 10, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@DaxterXS
DaxterXS force-pushed the fix/idc-device-login-stdin-feed branch from bca742a to 801bdcf Compare September 10, 2026 09:54
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 10, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 10, 2026
…cli kirodotdev#4243)

The enterprise sign-in path passes --identity-provider/--region to
kiro-cli login, but several kiro-cli builds still show interactive
prompts 'Enter Start URL' / 'Enter Region' (only --license is honored
non-interactively) — kiro-cli kirodotdev#4243. Those prompts are a TUI widget that
reads the CONTROLLING TTY, not stdin. The launcher runs login in the
background over SSM with no tty and stdin from /dev/null, so the prompts
never render or submit, no device-code URL is printed, capture times
out, and start_device_login wrongly falls back to the social/callback
path (confusing 'Google/GitHub needs a forwarded port' message).

The flags DO pre-fill each prompt's default; the widget just needs a tty
and an Enter per field. Fix, in _device_login_command: on the enterprise
path run login under a pseudo-tty via util-linux 'script -qec' and feed
newlines into that pty (printf '\n\n\n' piped in) to submit the
pre-filled values. Verified on Amazon Linux 2023: this emits the
device-code URL with no human interaction. KIRO is exported so the
script/sh -c subshell resolves the binary. If 'script' is absent, fall
back to a direct run with newlines on stdin. The Builder ID / social
path keeps no pty and stdin </dev/null, byte-for-byte unchanged.

Also in start_device_login: on the Identity Center path there is no
social/callback flow, so report an honest device-code timeout instead of
falling through to _start_callback_login.

Tests: Builder ID path unchanged; IdC path runs under 'script -qec' with
fed newlines and exports KIRO; values are shell-quoted (injection); the
resume command threads the same; an IdC timeout does not chase a social
callback port.
@DaxterXS
DaxterXS force-pushed the fix/idc-device-login-stdin-feed branch from e6fa683 to 1891f6e Compare September 14, 2026 09:51
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 14, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 14, 2026
@NicholasRBowers NicholasRBowers added the needs-pr-triage PR scanner: awaiting automated triage label Sep 20, 2026
@chenmingwei23 chenmingwei23 added needs-human-security-review Security scan flagged — needs manual review and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 20, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor

Kiro Crew [operator: chenmingwei23#de330d0c]: Security scan flagged this PR for manual review.

Findings:

  • code / test/test_cloud_login.py:128 - matched the destructive-command pattern on a test string evil = "https://x/$(touch /tmp/pwned)\id`; rm -rf ~ #"`. This is a hostile input fed to the login command builder to assert shell-quoting defense, not an executed directive. It appears benign, but the automated content scan cannot distinguish a defensive test fixture from a live command.

A maintainer will review before any automated action is taken.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 23, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Closing as superseded by PR #9840

Thanks for working on the IAM Identity Center device-login problem. PR #9840 (9ab334b435, merged 2026-09-17) fixed it on main. Main, with that fix in it, was merged into this branch on 2026-09-23 (de1e4dc633). Since then this diff replaces main's fix instead of adding to it.

Where main already has each goal (line numbers are on origin/main):

This PR origin/main
Run the IdC login under a pty that submits the prefilled Start URL and Region prompts _LOGIN_PTY_DRIVER at src/kiro_crew/cloud/login.py:98, staged in a mktemp -d dir at login.py:794-827 whenever any enterprise flag is set. Real-pty test at test/test_cloud_login_target.py:440
Keep the echoed Start URL out of the capture The driver drops prompt-echo lines (login.py:128-133), and parse_login_output(..., ignore_url=resolved.start_url) runs at login.py:478. Test at test_cloud_login_target.py:421
Never fall back to the social/callback flow on an IdC timeout if resolved.is_identity_center: # Pinned: stay on this identity. Report, do not degrade. at login.py:492-505. Test at test_cloud_login_target.py:375 (assert not fell_back)

At the audited head aad5aee2, merging would also break sign-in. The Opus 5 and GPT 5.6 reviews above already point this out:

  • login.py:497-503 reads identity_provider, idp_region and license_. None of these names exists inside start_device_login(..., target=...), and flake8 reports F821 on all four uses. Any login that captures no URL raises NameError, Builder ID logins included.
  • login.py:843 replaces {_login_dir_guard()} with export KIRO. That guard came from PR fix(cloud): write remote login state under a private per-user directory #11497 and is the only place KC_LOGIN_DIR gets set. Without it the log and pid paths become /kiro-login.log and /kiro-login.pid.

A rebase would not rescue it. The diff would end up either empty or removing main's code.

Two small things main doesn't have. Neither is worth keeping this open:

  • This PR's timeout message names the manual kiro-cli login --use-device-flow --license … --identity-provider … --region … command. Main's message (login.py:501-504) does not.
  • No main test checks that the resume path's IdC command runs under the driver. The code does route it through the driver, because _resume_login_command builds on _device_login_command (login.py:1026).

If main's _LOGIN_PTY_DRIVER fails on a particular kiro-cli build (for example, one whose prompt has no › caret), please open a new PR against the driver. That PR should keep _login_dir_guard(), the resolved.is_identity_center gating and the sentinel reporting. If I've missed something this PR covers, reopen it.

From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) needs-human-security-review Security scan flagged — needs manual review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants