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

Potential Issue with CurrHF and CurrINF Relationship After Decoding #4531

Closed
mlimbeck opened this issue May 23, 2024 · 4 comments
Closed

Potential Issue with CurrHF and CurrINF Relationship After Decoding #4531

mlimbeck opened this issue May 23, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@mlimbeck
Copy link

Hi everyone,
CC: @jcp19

While proving the correctness of the router in the context of VerifiedSCION, I tried to confirm that the current Infofield (CurrINF) and the current Hopfield (CurrHF) point to the same segment after decoding. Within the codebase, there exists the following function:

func (s *Base) infIndexForHF(hf uint8) uint8 {
	switch {
	case hf < s.PathMeta.SegLen[0]:
		return 0
	case hf < s.PathMeta.SegLen[0]+s.PathMeta.SegLen[1]:
		return 1
	default:
		return 2
	}
}

However, this function is only used in incPath, which is called either when the packet leaves the AS or a segment switch is performed. This happens very late in the processing of a packet. This could lead to potential problems in the router. In particular, the checks validateHopExpiry() and verifyCurrentMAC() could be performed with the wrong Infofield.

I am not sure if it is possible to satisfy verifyCurrentMAC() in this way, but if it is, the router would incorrectly perform an xover step, which is not supposed to happen.

So far, I haven't found a concrete counterexample, but it seems that the missing check can have a significant impact. Do you think such a check is necessary, or was it intentionally left out?

Thank you for your help.

@mlimbeck mlimbeck added the bug Something isn't working label May 23, 2024
@jcp19
Copy link
Contributor

jcp19 commented May 23, 2024

More generally, at the moment, the router seems to assume that the path is valid if parsePath returns successfully. After that point, the router might use that path, e.g., it may reverse it and use the result as the path of a SCMP packet. If we don't check the property above, the router might essentially produce packets with invalid paths.

@matzf
Copy link
Contributor

matzf commented May 27, 2024

As the info field and hop field information together is protected by the MAC, I think that this can't be exploited to circumvent path authorization. Still, I agree that it would seem prudent to check for this, to avoid forwarding (or replying to) packets with malformed path data.
We already have a issue to add general validation to the parsing layer, #4278. I've updated that to note that CurrHF should be checked to be in range for the CurrINF. In the meantime, it would seem appropriate to add a specific check for this into parsePath, as you're alluding to.

By the way; the path parser currently rejects truncated paths (length shorter than required for indicated number of hop fields), but allows longer paths (i.e paths with trailing garbage). I wonder if this should be forbidden for the same reason.

@jcp19
Copy link
Contributor

jcp19 commented May 27, 2024

By the way; the path parser currently rejects truncated paths (length shorter than required for indicated number of hop fields), but allows longer paths (i.e paths with trailing garbage). I wonder if this should be forbidden for the same reason.

For the time being, we haven't found any case where trailing garbage in the path is problematic for the router. However, we are currently addressing/verifying the last assumptions in the router, so we should be able to tell soon if that is actually the case.

matzf pushed a commit that referenced this issue Jul 11, 2024
This PR strengthens the checks performed by the `parsePath` method to
address the issues #4524 and
#4531. In particular, I added
two checks:
- We check that the `CurrHF` field of the parsed path is compatible with
the `CurrINF` field
- We check that non-peering segments have at least two hops

The proof that solution is correct is available in viperproject/VerifiedSCION#364
@matzf
Copy link
Contributor

matzf commented Jul 12, 2024

Fixed by #4556

@matzf matzf closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants