Skip to content

fix(security): harden credential storage and transmission#369

Merged
barrettruth merged 4 commits intomainfrom
fix/credential-security
Mar 7, 2026
Merged

fix(security): harden credential storage and transmission#369
barrettruth merged 4 commits intomainfrom
fix/credential-security

Conversation

@barrettruth
Copy link
Owner

Problem

Credential and cookie files were world-readable (0644), passwords transited via CP_CREDENTIALS env var (visible in /proc/PID/environ), and Kattis/USACO echoed passwords back through stdout unnecessarily.

Solution

Set 0600 permissions on cp-nvim.json and cookies.json after every write, pass credentials via stdin pipe instead of env var, and stop emitting passwords in ndjson from Kattis/USACO LoginResult (CSES token emission unchanged).

Problem: credential and cookie files were world-readable (0644),
passwords transited via `CP_CREDENTIALS` env var (visible in
`/proc/PID/environ`), and Kattis/USACO echoed passwords back
through stdout unnecessarily.

Solution: set 0600 permissions on `cp-nvim.json` and `cookies.json`
after every write, pass credentials via stdin pipe instead of env
var, and stop emitting passwords in ndjson from Kattis/USACO
`LoginResult` (CSES token emission unchanged).
Problem: After a failed login attempt, the user had to re-run
`:CP <platform> login` manually. Cancel messages lacked context, and
credential prompts in `submit.lua` used raw platform IDs instead of
display names.

Solution: `prompt_and_login` now recurses after failure so the user is
re-prompted until they cancel or succeed. `submit.lua` extracts the
scraper call into `do_submit` and re-prompts via `prompt_credentials` on
`bad_credentials`. Username prompts show `<Esc> to cancel`, and cancel
messages include the platform display name.
Problem: `:CP login` and `:CP logout` only worked as `:CP <platform>
login`. Users with an active platform or in a registered buffer had to
type the platform name redundantly.

Solution: Parse standalone `login`/`logout`/`signup` as action commands
with `requires_context = true`, resolving the platform from state (or
auto-restoring from the current buffer). Add `vim.cmd.redraw()` after
auto-restore so the screen updates before any prompt. Add `login`/
`logout` to top-level completion when a platform is active.
@barrettruth barrettruth merged commit b53c8ca into main Mar 7, 2026
9 of 10 checks passed
@barrettruth barrettruth deleted the fix/credential-security branch March 7, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant