Repository navigation
Операторское состояние открывается и без CLOUDRU_KEY_SECRET - #710
Conversation
Ключ состояния берётся из OPERATOR_STATE_KEY, затем из прежнего CLOUDRU_KEY_SECRET, затем из S3_SECRET_ACCESS_KEY; state restore перебирает их, так что ранее сохранённое состояние открывается как раньше. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXwerHR47mH3XGdoYs9NQN
Hacktron Security Check - SkippedReason: Code Review is not active for this organization
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="scripts/cloudru-app-host/host.py">
<violation number="1" location="scripts/cloudru-app-host/host.py:1105">
P2: `state_secrets` treats a lone `S3_SECRET_ACCESS_KEY` as usable, but `s3.py` selects S3 credentials only when all four `S3_*` settings exist. With a partial S3 setup and no Cloud secret, `cmd_state` passes the guard then crashes with `KeyError`; gate this fallback on `s3.PROVIDER` or validate the complete S3 configuration.</violation>
<violation number="2" location="scripts/cloudru-app-host/host.py:1134">
P2: Changing this message leaves the existing `HostCliTest` failing: its wrong-key and tamper assertions still require `does not open with this CLOUDRU_KEY_SECRET`. Update those assertions before merging.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
|
||
| def state_secrets(): | ||
| """The secrets a sealed state may be under, the one `state save` uses first.""" | ||
| names = ("OPERATOR_STATE_KEY", "CLOUDRU_KEY_SECRET", "S3_SECRET_ACCESS_KEY") |
There was a problem hiding this comment.
P2: state_secrets treats a lone S3_SECRET_ACCESS_KEY as usable, but s3.py selects S3 credentials only when all four S3_* settings exist. With a partial S3 setup and no Cloud secret, cmd_state passes the guard then crashes with KeyError; gate this fallback on s3.PROVIDER or validate the complete S3 configuration.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/cloudru-app-host/host.py, line 1105:
<comment>`state_secrets` treats a lone `S3_SECRET_ACCESS_KEY` as usable, but `s3.py` selects S3 credentials only when all four `S3_*` settings exist. With a partial S3 setup and no Cloud secret, `cmd_state` passes the guard then crashes with `KeyError`; gate this fallback on `s3.PROVIDER` or validate the complete S3 configuration.</comment>
<file context>
@@ -1097,6 +1100,12 @@ def derive(label):
+def state_secrets():
+ """The secrets a sealed state may be under, the one `state save` uses first."""
+ names = ("OPERATOR_STATE_KEY", "CLOUDRU_KEY_SECRET", "S3_SECRET_ACCESS_KEY")
+ return [os.environ[name] for name in names if os.environ.get(name, "").strip()]
+
</file context>
| names = ("OPERATOR_STATE_KEY", "CLOUDRU_KEY_SECRET", "S3_SECRET_ACCESS_KEY") | |
| names = ("OPERATOR_STATE_KEY", "CLOUDRU_KEY_SECRET") | |
| if s3.PROVIDER: | |
| names += ("S3_SECRET_ACCESS_KEY",) |
| if hmac.compare_digest(tag, hmac.new(mac_key, cipher, hashlib.sha256).digest()): | ||
| break | ||
| else: | ||
| sys.exit("the operator state does not open with OPERATOR_STATE_KEY, CLOUDRU_KEY_SECRET or S3_SECRET_ACCESS_KEY " |
There was a problem hiding this comment.
P2: Changing this message leaves the existing HostCliTest failing: its wrong-key and tamper assertions still require does not open with this CLOUDRU_KEY_SECRET. Update those assertions before merging.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/cloudru-app-host/host.py, line 1134:
<comment>Changing this message leaves the existing `HostCliTest` failing: its wrong-key and tamper assertions still require `does not open with this CLOUDRU_KEY_SECRET`. Update those assertions before merging.</comment>
<file context>
@@ -1112,13 +1121,18 @@ def seal(data, secret):
+ if hmac.compare_digest(tag, hmac.new(mac_key, cipher, hashlib.sha256).digest()):
+ break
+ else:
+ sys.exit("the operator state does not open with OPERATOR_STATE_KEY, CLOUDRU_KEY_SECRET or S3_SECRET_ACCESS_KEY "
+ "(rotated since `state save`?)")
read, write = os.pipe()
</file context>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXwerHR47mH3XGdoYs9NQN
Что меняется
host.py state save/restoreбольше не требуетCLOUDRU_KEY_SECRET. Ключ состояния берётся по очереди:OPERATOR_STATE_KEY, прежнийCLOUDRU_KEY_SECRET,S3_SECRET_ACCESS_KEY(с ним сессия и так ходит в бакет).state saveзапечатывает первым из заданных,state restoreперебирает все, поэтому состояние, сохранённое под прежним ключом, открывается как раньше.Компромисс
Последний вариант (ключ из S3-секрета) не даёт защиты сверх ключа бакета: у кого есть он, тот читает и шифртекст, и пароль. Прежняя схема с отдельным секретом защищала от утечки одних S3-ключей. Если нужна эта защита, достаточно задать
OPERATOR_STATE_KEY.Проверка
Проверил на настоящем
openssl: старое состояние открывается ключомCLOUDRU_KEY_SECRETпри любой комбинации переменных, состояние только под S3-ключом запечатывается и открывается, неверный ключ даёт понятную ошибку. Само состояние в бакете я не открывал (из облачной сессии нет доступа кbro-bucket).Generated by Claude Code
Summary by cubic
host.py state save/restoreno longer requiresCLOUDRU_KEY_SECRET. The state key now comes fromOPERATOR_STATE_KEY, falling back to the legacyCLOUDRU_KEY_SECRET, thenS3_SECRET_ACCESS_KEY;state saveseals with the first one set andstate restoretries each in turn, so state saved under the old key still opens.One caveat: the
S3_SECRET_ACCESS_KEYfallback protects nothing beyond the bucket's own keys—anyone with the bucket key can already read both the ciphertext and the passphrase. SetOPERATOR_STATE_KEYif you need that separation.Tests
OPERATOR_STATE_KEY>CLOUDRU_KEY_SECRET>S3_SECRET_ACCESS_KEY) and opening legacy state when a newer key is tried first.Written for commit 681f58d. Summary will update on new commits.