node-webid icon indicating copy to clipboard operation
node-webid copied to clipboard

Agent confusion issue

Open rkaw92 opened this issue 7 years ago • 7 comments

It seems that this implementation of the WebID TLS verifier does not handle fragment identifiers correctly. Let us take the example snippet from the README, and modify the WebID URI (that represents a real person, not the Profile URI) so that it points to another fragment:

// ...
subjectaltname: 'URI:https://test_nicola.databox.me/profile/card#somebodyelse'
// ...

If we run the script, the verification passes:

webid.verify(validCert, function(error, agentURI) {
  console.log('error: %s', error);
  console.log('agentURI: %s', agentURI);
});

The below is printed:

error: null
agentURI: https://test_nicola.databox.me/profile/card#somebodyelse

Even though there is no fragment "somebodyelse" in the file!

This is bad - if using an aggregated RDF file with multiple fragments representing different persons (a normal use case, according to WebID spec examples), we are able to impersonate any of them, provided that our key (modulus/exponent) exists anywhere in the same file.

The query used for finding the person fragment should probably be tweaked.

rkaw92 avatar Dec 20 '18 20:12 rkaw92

Good catch. I think it would be worth adding a test for this.

melvincarvalho avatar Dec 21 '18 08:12 melvincarvalho

I guess we should be adding a selector (is that the SparQL term?) that only regards statements about our particular subject (identified by the WebID IRI) when verifying, rather than querying by key only.

rkaw92 avatar Dec 21 '18 09:12 rkaw92

@RubenVerborgh it seems you're the closest to make an assessment about it, I'm pretty much at loss here.

kjetilk avatar Feb 04 '19 20:02 kjetilk

Proposed solution is right; currently, it selects all keys in the file, does not filter webid.

RubenVerborgh avatar Feb 04 '19 20:02 RubenVerborgh

Agreed.

Suggest the solution would be to add a test, with multiple webids in a single document.

Then use sparql to follow your nose and fix the failing test..

melvincarvalho avatar Feb 04 '19 21:02 melvincarvalho

OK, I'm unfamiliar with the code, and don't feel confident about fixing it, but concretely, this entails modifying the SPARQL query in https://github.com/linkeddata/node-webid/blob/master/tls/index.js#L14 so that ?webid isn't a variable, but set to the actual WebID?

kjetilk avatar Feb 04 '19 21:02 kjetilk

Indeed; we can also just string manipulate the query.

RubenVerborgh avatar Feb 05 '19 08:02 RubenVerborgh