Skip to content

Commit

Permalink
Prevent creating members on non-existent networks.
Browse files Browse the repository at this point in the history
```sh
curl -s -X POST "http://localhost:9993/controller/network/abcdabcdabcdabcd/member/1122334455"
```

Would return 200 and ZT_HOME/controller.d/abcdabcdabcdabcd/members/1122334455
would be created. Without a ZT_HOME/controller.d/abcdabcdabcdabcd.json

Then other parts of the system mistakenly think a abcdabcdabcdabcd
network sorta kinda exists and then fail in weird ways.
  • Loading branch information
laduke committed Feb 22, 2024
1 parent 4cd1dcf commit ce1c8cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controller/EmbeddedNetworkController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
sv6.Get(networkPath, networkGet);

auto createNewNetwork = [&, setContent](const httplib::Request &req, httplib::Response &res) {
fprintf(stderr, "creating new network (new style)\n");
// fprintf(stderr, "creating new network (new style)\n");
uint64_t nwid = 0;
uint64_t nwidPrefix = (Utils::hexStrToU64(_signingIdAddressString.c_str()) << 24) & 0xffffffffff000000ULL;
uint64_t nwidPostfix = 0;
Expand Down Expand Up @@ -1136,6 +1136,12 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
auto memberID = req.matches[2].str();
uint64_t nwid = Utils::hexStrToU64(networkID.c_str());
uint64_t memid = Utils::hexStrToU64(memberID.c_str());

if (!_db.hasNetwork(nwid)) {
res.status = 404;
return;
}

json network;
json member;
_db.get(nwid, network, memid, member);
Expand Down

0 comments on commit ce1c8cc

Please sign in to comment.