#5429·atproto

verifyRepoCar() 接受无效的仓库路径和非标准的 MST

作者: olix0r创建于 2026年8月19日更新于 2026年8月20日

import { createHash } from 'node:crypto'

import { Secp256k1Keypair } from '@atproto/crypto' import { encode } from '@atproto/lex-cbor' import { cidForCbor } from '@atproto/lex-data' import { BlockMap, MemoryBlockstore, concatBytesAsync, getFullRepo, signCommit, verifyRepoCar, } from '@atproto/repo'

const did = 'did:example:repo-verifier' const keypair = await Secp256k1Keypair.import( '0000000000000000000000000000000000000000000000000000000000000001', { exportable: true }, ) const recordKey = 'com.example.fixture1/main' const recordBytes = encode({ $type: 'com.example.fixture1', value: 'record' }) const recordCid = await cidForCbor(recordBytes) const markerBytes = encode({ $type: 'com.example.marker', value: 'marker' }) const markerCid = await cidForCbor(markerBytes) const parentLayer = mstLayer(recordKey)

const wrongLayerKey = findKey( 'com.example.wrongLayer', (key) => key > recordKey && mstLayer(key) !== parentLayer - 1, ) const outOfRangeKey = findKey( 'com.example.aaaRange', (key) => key < recordKey && mstLayer(key) === parentLayer - 1, ) const [prefixLeft, prefixRight] = findSameLayerKeys('com.example.prefix')

const cases = [ { name: 'unnormalized repository-path NSID', graph: async () => ({ root: await mstNode([mstEntry('COM.example.fixture1/main', recordCid)]), children: [], records: [[recordCid, recordBytes]], }), }, { name: 'key on the wrong MST layer', graph: async () => { const child = await …

内容来源: bluesky-social/atproto