mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
event::ExecuteCommand: add missing origin check
Only handle messages with a trusted origin in ClusterEvents::ExecuteCommandAPIHandler. Previously, it would not locally execute any command but forward them to other nodes where they would then have a trusted origin and be executed.
This commit is contained in:
parent
0a362937b3
commit
8f585bd2ee
@ -736,6 +736,31 @@ Value ClusterEvents::ExecuteCommandAPIHandler(const MessageOrigin::Ptr& origin,
|
|||||||
if (!listener)
|
if (!listener)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
|
if (!origin->IsLocal()) {
|
||||||
|
Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
|
||||||
|
|
||||||
|
/* Discard messages from anonymous clients */
|
||||||
|
if (!endpoint) {
|
||||||
|
Log(LogNotice, "ClusterEvents") << "Discarding 'execute command' message from '"
|
||||||
|
<< origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
|
||||||
|
return Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
Zone::Ptr originZone = endpoint->GetZone();
|
||||||
|
|
||||||
|
Zone::Ptr localZone = Zone::GetLocalZone();
|
||||||
|
bool fromLocalZone = originZone == localZone;
|
||||||
|
|
||||||
|
Zone::Ptr parentZone = localZone->GetParent();
|
||||||
|
bool fromParentZone = parentZone && originZone == parentZone;
|
||||||
|
|
||||||
|
if (!fromLocalZone && !fromParentZone) {
|
||||||
|
Log(LogNotice, "ClusterEvents") << "Discarding 'execute command' message from '"
|
||||||
|
<< origin->FromClient->GetIdentity() << "': Unauthorized access.";
|
||||||
|
return Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (params->Contains("endpoint")) {
|
if (params->Contains("endpoint")) {
|
||||||
Endpoint::Ptr execEndpoint = Endpoint::GetByName(params->Get("endpoint"));
|
Endpoint::Ptr execEndpoint = Endpoint::GetByName(params->Get("endpoint"));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user