When using unscoped capabilities (e.g., ucan:*), rs-ucan converts this "with" into * and omits the URI scheme:
|
"*" => ResourceUri::Unscoped, |
this alone is probably a security issue (e.g., ucan:* is not equal to https:* for capability purposes), but has the unfortunate downside that unscoped capabilities are then not usable for the purposes of chain validation:
|
let uri = Url::parse(resource).ok()?; |
In the above, the scope (which has been down-converted to simply * from e.g. ucan:*) is re-parsed and silently fails (use of anyhow here masks this error), returning None instead of the otherwise-valid capability.
The workaround is easy, i.e. just don't use unscoped capabilities, but flagging this here for a future fix. A fix should be as simple as either not using Unscoped at all (literally removing this line,
|
"*" => ResourceUri::Unscoped, |
fixes the brokenness) and switching to only scoped capabilities, or adding a URI scheme to the
Unscoped Resource type (as
Scoped has).
I don't know what the motivation behind treating unscoped capabilities differently was, so I'll hold off on contributing a patch for now but lmk!
When using unscoped capabilities (e.g.,
ucan:*), rs-ucan converts this "with" into*and omits the URI scheme:rs-ucan/ucan/src/capability/semantics.rs
Line 139 in 83528cc
this alone is probably a security issue (e.g.,
ucan:*is not equal tohttps:*for capability purposes), but has the unfortunate downside that unscoped capabilities are then not usable for the purposes of chain validation:rs-ucan/ucan/src/capability/semantics.rs
Line 160 in 83528cc
In the above, the scope (which has been down-converted to simply
*from e.g.ucan:*) is re-parsed and silently fails (use of anyhow here masks this error), returningNoneinstead of the otherwise-valid capability.The workaround is easy, i.e. just don't use unscoped capabilities, but flagging this here for a future fix. A fix should be as simple as either not using Unscoped at all (literally removing this line,
rs-ucan/ucan/src/capability/semantics.rs
Line 139 in 83528cc
UnscopedResourcetype (asScopedhas).I don't know what the motivation behind treating unscoped capabilities differently was, so I'll hold off on contributing a patch for now but lmk!