-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix /machine/map endpoint vulnerability
#2642
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
Changes from 1 commit
ae30020
7610e8c
fe97600
e03ec31
84337b5
339a9cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,9 +209,8 @@ func (ns *noiseServer) NoisePollNetMapHandler( | |
| return | ||
| } | ||
|
|
||
| ns.nodeKey = mapRequest.NodeKey | ||
| node, err := ns.headscale.db.GetNodeByMachineKey(ns.machineKey) | ||
|
|
||
| node, err := ns.headscale.db.GetNodeByNodeKey(mapRequest.NodeKey) | ||
| if err != nil { | ||
| if errors.Is(err, gorm.ErrRecordNotFound) { | ||
| httpError(writer, NewHTTPError(http.StatusNotFound, "node not found", nil)) | ||
|
|
@@ -221,6 +220,13 @@ func (ns *noiseServer) NoisePollNetMapHandler( | |
| return | ||
| } | ||
|
|
||
| if ns.nodeKey != mapRequest.NodeKey { | ||
| httpError(writer, NewHTTPError(http.StatusNotFound, "node does not belong to machine key", nil)) | ||
| return | ||
| } | ||
|
||
|
|
||
| ns.nodeKey = node.NodeKey | ||
|
||
|
|
||
| sess := ns.headscale.newMapSession(req.Context(), mapRequest, writer, node) | ||
| sess.tracef("a node sending a MapRequest with Noise protocol") | ||
| if !sess.isStreaming() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hscontrol/noise.go, the error message 'node does not belong to machine key' on line 224 might be confusing. Consider changing it to something more precise like 'node key in request doesn't match the one associated with this machine key' to clarify the exact validation that's failing.