Skip to content

rpcutils+rpcserver: reject unknown rpc asset type and sort values - #2397

Open
jtobin wants to merge 1 commit into
lightninglabs:mainfrom
jtobin:issue565
Open

jtobin wants to merge 1 commit into
lightninglabs:mainfrom
jtobin:issue565

Conversation

@jtobin

@jtobin jtobin commented Nov 25, 2026

Copy link
Copy Markdown
Member

Resolves #565.

I just happened to opportunistically pick this up while dredging through old issues; it improves some invalid-value handling and fixes an RPC/internal enum mismatch on universe.SyncStatsSort.

UnmarshalAssetType rejects values outside the defined asset types.
MintAsset and UnmarshalGenesisInfo unmarshal the RPC asset type field
through UnmarshalAssetType instead of a raw type conversion.

unmarshalUniSyncStatsSort maps the RPC asset query sort field to its
universe.SyncStatsSort counterpart and rejects unrecognized values.
QueryAssetStats unmarshals its sort field through
unmarshalUniSyncStatsSort instead of a raw type conversion.
Comment thread rpcserver/rpcserver.go
case unirpc.AssetQuerySort_SORT_BY_ASSET_NAME:
return universe.SortByAssetName, nil

case unirpc.AssetQuerySort_SORT_BY_ASSET_ID:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use rows whose ID and type orders differ to test both sort modes through QueryAssetStats. Also assert that an unknown sort fails before querying the store.

Comment thread rpcserver/rpcserver.go
limit = universe.RequestPageSize
}

sortBy, err := unmarshalUniSyncStatsSort(req.SortBy)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

An unknown AssetTypeFilter silently turns this into an unfiltered query. Handle FILTER_ASSET_NONE explicitly and reject unknown values.

Comment thread rpcserver/rpcserver.go
"and group internal key descriptor")
}

assetType, err := rpcutils.UnmarshalAssetType(req.Asset.AssetType)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Exercise the caller paths too. Assert that MintAsset rejects an unknown type before queueing and that group key request decoding rejects an unknown anchor asset type.

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

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

Audit RPC enum handling

2 participants