Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: process problem report message #1859

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@ describe('V1CredentialProtocol', () => {
}
expect(credentialRepository.getSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, {
threadId: 'somethreadid',
connectionId: connection.id,
})
expect(repositoryUpdateSpy).toHaveBeenCalledTimes(1)
const [[, updatedCredentialRecord]] = repositoryUpdateSpy.mock.calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ describe('V1ProofProtocol', () => {
}
expect(proofRepository.getSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, {
threadId: 'somethreadid',
connectionId: connection.id,
})
expect(repositoryUpdateSpy).toHaveBeenCalledTimes(1)
const [[, updatedCredentialRecord]] = repositoryUpdateSpy.mock.calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,10 @@ export abstract class BaseCredentialProtocol<CFs extends CredentialFormatService
): Promise<CredentialExchangeRecord> {
const { message: credentialProblemReportMessage, agentContext } = messageContext

const connection = messageContext.assertReadyConnection()

agentContext.config.logger.debug(`Processing problem report with message id ${credentialProblemReportMessage.id}`)

const credentialRecord = await this.getByProperties(agentContext, {
threadId: credentialProblemReportMessage.threadId,
connectionId: connection.id,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

This is dangerous as it allows anyone to send a response to the credential exchange by knowing the thread id. For this reason we don't support problem reports currently for connectionsless exchanges.

If we want to support this, we need to handle it the same as is done in the processRequest message. Which consists of:

  • query the record without connection id
  • then if the record has a connection id:
    • check if it matches the connection id from the exchange
  • if the record does not have a connection id:
    • check that the problem report is authorized based on the out of band exchange (the parentThreadId also need to match)
    • if the incoming message has a connection associated, update the connectionId in the exchange record

This is already implemented like this for processRequest, and I think you can copy most of the logic


// Update record
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,6 @@ describe('credentialProtocol', () => {

expect(credentialRepository.getSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, {
threadId: 'somethreadid',
connectionId: '123',
})
expect(credentialRepository.update).toHaveBeenCalled()
expect(returnedCredentialRecord.errorMessage).toBe('issuance-abandoned: Indy error')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,12 @@
public async processProblemReport(
messageContext: InboundMessageContext<ProblemReportMessage>
): Promise<ProofExchangeRecord> {
const { message: proofProblemReportMessage, agentContext, connection } = messageContext

Check warning on line 113 in packages/core/src/modules/proofs/protocol/BaseProofProtocol.ts

View workflow job for this annotation

GitHub Actions / Validate

'connection' is assigned a value but never used

agentContext.config.logger.debug(`Processing problem report with message id ${proofProblemReportMessage.id}`)

const proofRecord = await this.getByProperties(agentContext, {
threadId: proofProblemReportMessage.threadId,
connectionId: connection?.id,
})

// Update record
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ describe('V2ProofProtocol', () => {
}
expect(proofRepository.getSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, {
threadId: 'somethreadid',
connectionId: connection.id,
})
expect(repositoryUpdateSpy).toHaveBeenCalledTimes(1)
const [[, updatedCredentialRecord]] = repositoryUpdateSpy.mock.calls
Expand Down
Loading