Repository navigation
Conversation
Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The only OS-image control is the KMS-global allowlist (
DstackKms.allowedOsImages). On the shared KMS it admits development images, dstack-0.6.1 (GHSA-c79w-3x5w-gmm5) and every older release, and an app owner cannot exclude any of them.IAppAuth.AppInfoalready carriesosImageHashinto the app policy, butDstackAppignores it, so an app's keys are released to any image the KMS owner admits. Related: #1293 (the KMS owner's only revocation lever is the global allowlist).Fix
DstackAppgets its own OS image allowlist. The KMS checks its allowlist before forwarding to the app, so the effective policy is KMS ∩ app and the app list can only narrow it.allowAnyOsImage()/setAllowAnyOsImage(bool): one switch over every app epoch, likeallowAnyDevice/allowAnyTeeVariant. It is on by default, so existing and new apps keep today's behaviour.add/removeOsImageHashAtEpoch(s)andallowedOsImagesAtEpoch: per-app-epoch rows, like compose hashes and devices, with the same writable-epoch rule and the_setAtEpochsrange helper._authorizeApprejects an unlisted image withOS image not allowedwhile the switch is off. The image is inAppInfo, so the legacyisAppAllowedenforces it too (unlike TEE variants).AllowAnyOsImageSet,EpochPolicyChanged("os-image", ...)for every row, andPolicyChangedfor the switch and for row 0, as the KMS does for its OS images.bool _osImagesRestricted(slot 11, zero = unrestricted, so upgraded proxies stay open) andmapping(uint256 => mapping(bytes32 => bool)) _osImagesByEpoch(slot 12).__gapgoes from 42 to 40, so slots 0–10 and the end of the gap are unchanged. No reinitializer is needed.version()stays 2, as it did for the epoch, TEE-variant and launch-ticket additions.IAppEpochManagementis unchanged: its ID0x8c0524c4shipped in 0.6.4 and tools detect apps by it. The new setters live onDstackApponly, like the launch-ticket setters.Manage.s.sol:AddAppOsImage/RemoveAppOsImagetakeAPP_EPOCHor a range.SetAllowAnyAppOsImagerefuses an epoch, and all three refuse apps that predate app epochs.Query.s.sol GetAppSettingsprints the switch.dstack-auth(the replacement for the removedauth-simple) gets the same narrowing as an optionalapps.<appId>.osImages. It has no per-app epochs, and leaving the field out keeps today's behaviour.onchain-governance.md,app-key-epochs.md,dstack-auth-operations.md,auth-eth/script/README.md, CHANGELOG.The auth-eth webhook (
index.ts) already passesosImageHashthrough unchanged, so it needs no change.Verification
In
dstack/kms/auth-eth, with the submodules and@openzeppelin/upgrades-coreset up as in CLAUDE.md:forge build: compiles. DstackApp runtime size is 15,178 bytes (was 14,117).forge clean && forge test --ffi: 122 passed, 0 failed, including the OZ upgrade validation ofDstackAppagainst the released v0.5.9 and v0.6.0 layouts.authorizeAppand the legacyisAppAllowed.DstackKms, an image only the app lists is still refused (OS image is not allowed).forge inspect DstackApp storageLayoutconfirms slots 0–10 matchnext.cargo test -p dstack-auth: 18 passed.cargo clippy -p dstack-auth -- -D warnings -D clippy::unwrap_used -D clippy::expect_usedandcargo fmt --all --checkare clean.Follow-up
EpochPolicyChanged.deployAndRegisterApp/ the initializers cannot set an initial OS image list. An owner who needs a restriction from the first boot should deploy withoutINITIAL_COMPOSE_HASH, restrict, then add the compose hash.