Skip to content

[BUG] [v0.0.7] run_logout can log the user out when stdin confirmation reading fails silently #52531

Description

@johncur-super

Project

cortex

Description

In run_logout, the confirmation step before logout treats std::io::stdin().read_line() errors as if nothing went wrong. When that read fails because of an I/O issue such as a broken pipe or unavailable input, the function continues to logout_with_fallback() and deletes stored credentials without receiving confirmation. This creates a fail-open path in a destructive action, where an unreadable prompt should instead cancel the logout or return an explicit error.
Affected function: run_logout
Affected lines: The confirmation prompt block containing if std::io::stdin().read_line(&mut input).is_ok()

Error Message

Debug Logs

System Information

Cortex: 0.0.7 OS: Ubuntu 24.04

Screenshots

https://github.com/johncur-super/images/blob/main/63.png

Steps to Reproduce

Run cortex logout without the --yes flag in an interactive terminal
Cause stdin to enter an error state (e.g., by closing the stdin file descriptor or triggering an I/O error during the prompt)
Observe that the program proceeds to logout despite being unable to read the confirmation response

Expected Behavior

If the confirmation prompt cannot be read due to an I/O error, the logout should be cancelled or an error should be reported. The destructive operation should not proceed when user intent cannot be determined.

Actual Behavior

The program silently ignores the stdin read error and proceeds to remove the user's stored credentials, logging them out without confirmation.

Additional Context

This breaks fail-safe behavior for destructive actions. When read_line returns Err, the code should handle that failure explicitly instead of falling through to the logout path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingideIssues related to IDEvalidValid issue

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions