Open
Conversation
This relates the abstraction of the computed MAC tag to the one computed from the abstracted arguments, s.t. we can assert `hf_valid` from there.
…to mac-assumption
…into mac-assumption
jcp19
reviewed
Mar 6, 2025
jcp19
reviewed
Mar 6, 2025
I also adjusted the code to match the "new style conventions" (e.g. space between // and @)
…into mac-assumption-scratch
Contributor
Author
|
( |
Collaborator
|
@henriman are you using a different config for the router locally? |
Contributor
Author
It seems that the issue was due to me using a slightly outdated version of Gobra. With the most up-to-date version, I was able to reproduce and fix the issue (by adding an additional assert). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At the moment, we simply assume that
hf_validholds after the comparison inrouter/dataplane.go,verifyCurrentMAC. This PR moves the assumption deeper into the code (intopath.FullMAC), by instead assuming that the abstraction of the result ofpath.FullMACequals the abstract computation of the MAC on the abstraction of the info and hop fields.Besides slightly reducing the assumption, this change is necessary in order to be able to declassify the MAC tag when proving secure information flow (cf. #394, #409): This needs to happen before comparing it to the given tag (using
subtle.ConstantTimeCompareinverifyCurrentMAC,processOHP) -- to satisfy low control flow, but also because the result of this comparison is exactly what is leaked about the router's key. Consequently, we need to abstractly describe thatFullMAC/MACcompute such MAC tags s.t. we can allow declassification at this point.Approach
In order to keep track of which AS's secret key is used by the hash instances produced by
DataPlane.macFactory/by the hash instance saved inscionPacketProcessor.mac, we define an extension of thehash.Hashinterface calledScionHashSpecwhich allows us to access the corresponding AS identifier using functionScionHashSpec.Asid.Asiddirectly tohash.Hashas this is specific to VerifiedSCION. Consequently (as e.g.scionPacketProcessor.macneeds to remain of typehash.Hash), we save theScionHashSpec"version" ofmacinscionPacketProcessor.macSpecand relate them usingmac === macSpec.Asidreturns the correct AS identifier inSetKey(using the appropriately adaptedInitMacfunction). This information is then propagated forp scionPacketProcessorusingp.macSpec.Asid() == dp.Asid().In
FullMAC/MAC, besidesh hash.Hashwe then also passsh hash.ScionHashSpec(whereh === sh); this allows us to describe the corresponding abstract computation by passingsh.Asid()toio.nextMsgtermSpec.See the comments below for further discussion explaining the need for this approach.
Status
This is done. However, as I needed to adapt the contracts of
SetIAand ´SetKey, one _should_ adaptrouter/dataplane_spec_test.gobra` to show that these contracts are satisfiable (although I am certain they are).Adapting
router/dataplane_spec_test.gobra.As the current tests don't call
SetIAorSetKey, but rather set these fields directly, this requires a few modifications. The main issue that I came across was the fact that we pass full permissions to(*DataPlane).Mem(counting the permissions in the mutex) to these methods; consequently, after a call to e.g.SetIA, we are not able to establish that some properties dependent on unrelated fields ofDataPlanestill hold.I have started adapting this test in branch
mac-assumption-dataplane-testof my fork of VerifiedSCION (though I did not come far). The approach I have taken thus far was to change the contracts ofSetIA,SetKeyto only require partial permissions to(*DataPlane).Memand full permissions to the fields that are actually modified.However, this is not very clean. @jcp19 suggested the following approach instead:
DataPlanewhich contains only the relevant fields, without permissions (e.g. save aseqinstead of a slice).Absthat returns such an abstraction for a givenDataPlane.SetIA, we could have the following function:In order to prove these contracts, it might be helpful to use the approach I initially used -- i.e. only passing full permissions to the fields that are actually modified -- in the contract of an
outlineblock within the "top-level method".