Skip to content

fix: load Moltbook agent keys from env - #4610

Closed
douglance wants to merge 1 commit into
Scottcjn:mainfrom
douglance:fix/moltbook-env-agent-keys
Closed

douglance wants to merge 1 commit into
Scottcjn:mainfrom
douglance:fix/moltbook-env-agent-keys

Conversation

@douglance

Copy link
Copy Markdown
Contributor

Summary

  • replace committed Moltbook bearer-token values with per-agent environment variable names
  • only return available Moltbook agents when their credential env var is configured
  • update solver tests to use non-secret-shaped dummy tokens

Fixes #4609.

Security note

The previously committed Moltbook credentials should be rotated out of band. This PR avoids repeating the raw token values and removes secret-shaped Moltbook literals from the source/test paths.

Validation

  • rg -n "moltbook_sk_[A-Za-z0-9_-]+" scripts node tests tools integrations --glob "!**/get-pip.py" --glob "!**/package-lock.json" -> no matches
  • python3 -m py_compile scripts/moltbook_solver.py scripts/tests/test_moltbook_solver.py
  • uv run --no-project --with pytest --with requests python -m pytest scripts/tests/test_moltbook_solver.py -q -> 23 passed
  • python3 tools/bcos_spdx_check.py --base-ref origin/main -> OK

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines labels May 11, 2026

@saim256 saim256 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after focused security review of the Moltbook credential-removal patch.

What I checked:

  • The committed moltbook_sk_* bearer-token literals are removed from scripts/moltbook_solver.py and replaced with per-agent environment variable names.
  • get_agent_key() now resolves credentials at runtime from the configured env var, so no raw Moltbook bearer secret needs to live in the source tree.
  • get_available_agents() filters out agents whose key env var is unset, which prevents post_with_rotation() from attempting unauthenticated empty-key requests.
  • The preferred agent order and suspension filtering behavior are preserved for configured agents.
  • The updated tests use non-secret-shaped dummy token values and cover configured and missing-env cases.
  • Existing exposed Moltbook credentials still need out-of-band rotation, as noted in the PR body, but this patch stops re-exposing them in code/tests.

Validation run locally:

python -m pytest scripts\tests\test_moltbook_solver.py -q
# 23 passed

python -m py_compile scripts\moltbook_solver.py scripts\tests\test_moltbook_solver.py
# passed

rg -n "moltbook_sk_[A-Za-z0-9_-]+" scripts node tests tools integrations --glob "!**/get-pip.py" --glob "!**/package-lock.json"
# no matches

python tools\bcos_spdx_check.py --base-ref origin/main
# BCOS SPDX check: OK

No blocker found in this focused review.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

@godd-ctrl godd-ctrl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

I independently reviewed the Moltbook credential-removal patch on current head c6b29ee05f19b46444e688151ea704e1b9726cf5.

What I checked:

  • The raw moltbook_sk_* values are removed from scripts/moltbook_solver.py and replaced with per-agent environment variable names.
  • get_agent_key() now resolves the configured env var at runtime and returns None when it is unset, so missing credentials do not become empty/invalid bearer tokens.
  • get_available_agents() now filters out suspended agents and agents without configured env credentials before post_with_rotation() can choose them.
  • The tests use non-secret-shaped dummy token values and cover both configured and missing-env behavior.
  • The PR correctly notes that previously exposed credentials still need out-of-band rotation.

Validation run locally:

python -m pytest scripts\tests\test_moltbook_solver.py -q
# 23 passed

python -m py_compile scripts\moltbook_solver.py scripts\tests\test_moltbook_solver.py
# passed

git diff --check origin/main...HEAD -- scripts\moltbook_solver.py scripts\tests\test_moltbook_solver.py
# passed

rg -n 'moltbook_sk_[A-Za-z0-9_-]+' scripts node tests tools integrations --glob '!**/get-pip.py' --glob '!**/package-lock.json'
# no matches

python tools\bcos_spdx_check.py --base-ref origin/main
# BCOS SPDX check: OK

No blocking findings from this focused security review.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

@loganoe loganoe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the Moltbook credential cleanup.

The agent registry now stores environment variable names instead of committed token values, available agents are filtered to configured credentials, and the tests use non-secret dummy values. I also checked for remaining Moltbook key-shaped literals in the relevant source/test paths and found none.

Validation run:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=scripts /tmp/rustchain-flask-venv/bin/python -m pytest -q scripts/tests/test_moltbook_solver.py -> 23 passed
  • /tmp/rustchain-flask-venv/bin/python -m py_compile scripts/moltbook_solver.py scripts/tests/test_moltbook_solver.py -> passed
  • rg -n 'moltbook_sk_[A-Za-z0-9_-]+' scripts node tests tools integrations --glob '!**/get-pip.py' --glob '!**/package-lock.json' -> no matches
  • git diff --check origin/main...HEAD -- scripts/moltbook_solver.py scripts/tests/test_moltbook_solver.py -> passed

@TJCurnutte TJCurnutte left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hermes Agent review — APPROVED

I reviewed the diff for PR #4610: fix: load Moltbook agent keys from env

Validation proof

  • git diff --check: PASS
  • BCOS SPDX check: PASS
  • added-line secret-pattern scan: PASS
  • python py_compile: PASS
  • focused changed-test pytest: PASS

Scope checked
scripts/moltbook_solver.py (+11/-8), scripts/tests/test_moltbook_solver.py (+13/-5)

Review note
The changed surface is bounded and the local gates above did not expose whitespace, SPDX, syntax, focused-test, or added-secret regressions. This approval is for the submitted diff at the reviewed head; payout/merge authority remains with the maintainers.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

@Scottcjn

Copy link
Copy Markdown
Owner

Codex audit ✓ — this PR is approved for merge at high-tier (50 RTC) (Removes committed Moltbook agent keys from source and loads them from environment variables instead.).

Branch is currently behind main; rebase against latest tip and this'll merge.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing. Approved.

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great contribution to the RustChain ecosystem. Thanks for keeping the codebase clean and well-tested. Approved ✅

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Scottcjn

Copy link
Copy Markdown
Owner

Closing as stale branch — would cause destructive deletions if merged.

Your branch is 966 commits behind current main. Filed during the May 11-13 contributor burst, the codebase has since moved substantially. GitHub's mergeable=clean indicator doesn't detect this; only an explicit git diff main..your-branch --shortstat does.

Bounty credit acknowledged where applicable

Most of the canonical fixes from your work-period have already shipped via other contributors' parallel PRs that landed earlier this week. Specific cases credited via the Codex audit batches:

If you want fresh review

Rebase against current main and verify your diff matches the size of your original changes:

git fetch upstream main
git rebase upstream/main
git diff main..HEAD --shortstat

If the deletion count is much higher than what you intended, the branch is still picking up stale assumptions — recreate from a fresh main.

Thanks for the contribution work.

@Scottcjn Scottcjn closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hardcoded Moltbook bearer tokens in solver script

8 participants