Skip to content

Scanner fails to read credentials from Socket CLI v2 settings (directory vs file path mismatch) #9

Closed

Description

@dringrayson

Summary

The bun security scanner cannot read authentication credentials saved by socket login, causing it to silently fall back to free mode even when valid credentials exist.

Root Cause

The scanner reads credentials from a hardcoded path assuming a flat file:

~/.local/share/socket/settings

(src/index.ts L14-L39 constructs path.join(dataHome, 'socket', 'settings') and calls Bun.file() on it)

However, the Socket CLI (v2) writes credentials to a directory structure:

~/.local/share/socket/settings/config.json

Since settings is a directory, Bun.file(defaultSettingsPath).exists() returns false and the scanner falls through to unauthenticated mode with no error, only the generic warning:

⚠ Socket Security Scanner free mode. Set SOCKET_API_KEY to use your Socket org settings.

Steps to Reproduce

  1. socket login (authenticate successfully)
  2. Confirm credentials exist: cat ~/.local/share/socket/settings/config.json (base64-encoded JSON with apiToken)
  3. Run bun install with the scanner configured in bunfig.toml
  4. Observe "free mode" warning despite valid credentials

Expected Behavior

The scanner should read the token from ~/.local/share/socket/settings/config.json when the CLI has written credentials there.

Suggested Fix

In src/index.ts, after the current file check fails, fall back to checking the directory layout:

const defaultSettingsPath = path.join(dataHome, 'socket', 'settings')
let file = Bun.file(defaultSettingsPath)

if (!await file.exists()) {
  file = Bun.file(path.join(defaultSettingsPath, 'config.json'))
}

if (await file.exists()) {
  // ... existing base64 decode logic
}

Workaround

Set the env var explicitly:

export SOCKET_API_KEY="<token from ~/.local/share/socket/settings/config.json>"

Environment

  • OS: Ubuntu 24.04 (Linux x64)
  • Bun: 1.3+
  • Socket CLI: v2 (installed via bun install -g @socketsecurity/cli)
  • Scanner: @socketsecurity/bun-security-scanner@1.1.2

Activity

  1. added 4 commits that reference this issue on Feb 18, 2026
    b39ef67
    fefaad1
    4051bba
    a641337
  2. jdalton commented on Sep 8, 2026

    @jdalton
    Collaborator

    fix(scanner): read socket cli directory credentials

    Fixed on main in c9ef6e7. The scanner reads both settings and settings/config.json; an explicit environment token takes precedence.

    The credential regressions pass, including the directory layout and an unreadable flat entry. This fix is not yet in an npm release.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions