复现流程:
- 打开飞书的事件加密功能
- 使用"自定义适配器"模式
- 发送事件,出现verification failed event
代码片段:
@Post()
async on_event(@Body() body,@Headers() headers){
const data = {
reqData:body,
headers
}
const { isChallenge, challenge } = generateChallenge(body, {
encryptKey: this.lark_dispatcher.encryptKey
});
if(isChallenge){
return challenge
}
const result = await this.lark_dispatcher.invoke(data)
if(result instanceof CardActionHandler)
return result
return {}
}
经过追踪,疑似checkIsEventValidated函数中(
|
timestamp + nonce + this.encryptKey + JSON.stringify(data); |
),直接对
data作了Hash运算,而此时的data中存在“headers”对象,因此Hash不一致
复现流程:
代码片段:
经过追踪,疑似
checkIsEventValidated函数中(node-sdk/dispatcher/request-handle.ts
Line 104 in 6bf94c9
data作了Hash运算,而此时的data中存在“headers”对象,因此Hash不一致