1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

librpc: Add named_pipe_auth_req_info5->transport

This will serve as a check to make sure that in particular a SAMR
client is really root. This is for example used in get_user_info_18()
handing out a machine password.

The unix domain sockets for NCACN_NP can only be contacted by root,
the "np\" subdirectory for those sockets is root/root 0700.

Connecting to such a socket is done in two situations: First, local
real root processes connecting and smbd on behalf of SMB clients
connecting to \\pipe\name, smbd does become_root() there. Via the
named_pipe_auth_req_info4 smbd hands over the SMB session information
that the RPC server blindly trusts. The session information (i.e. the
NT token) is heavily influenced by external sources like the KDC. It
is highly unlikely that we get a system token via SMB, but who knows,
this is information not fully controlled by smbd.

This is where this additional field in named_pipe_auth_req_info5 makes
a difference: This field is set to NCACN_NP by smbd's code, not
directly controlled by the clients. Other clients directly connecting
to a socket in "np\" is root anyway (only smbd can do become_root())
and can set this field to NCALRPC.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Volker Lendecke 2021-11-27 16:38:38 +01:00
parent 530fb4fdfb
commit 1bab76223c
5 changed files with 12 additions and 0 deletions

View File

@ -60,6 +60,7 @@ struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const char *directory,
const char *npipe,
enum dcerpc_transport_t transport,
const struct tsocket_address *remote_client_addr,
const char *remote_client_name_in,
const struct tsocket_address *local_server_addr,
@ -121,6 +122,9 @@ struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
state->auth_req.level = 5;
info5 = &state->auth_req.info.info5;
info5->transport = transport;
SMB_ASSERT(info5->transport == transport); /* Assert no overflow */
info5->remote_client_name = remote_client_name_in;
info5->remote_client_addr = tsocket_address_inet_addr_string(remote_client_addr,
state);

View File

@ -20,6 +20,9 @@
#ifndef NPA_TSTREAM_H
#define NPA_TSTREAM_H
#include <replace.h>
#include "librpc/rpc/rpc_common.h"
struct tevent_req;
struct tevent_context;
struct auth_session_info_transport;
@ -30,6 +33,7 @@ struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const char *directory,
const char *npipe,
enum dcerpc_transport_t transport,
const struct tsocket_address *remote_client_addr,
const char *remote_client_name_in,
const struct tsocket_address *local_server_addr,

View File

@ -13,6 +13,7 @@ interface named_pipe_auth
const char *NAMED_PIPE_AUTH_MAGIC = "NPAM";
typedef [public] struct {
uint8 transport;
[charset(UTF8),string] uint8 *remote_client_name;
[charset(DOS),string] uint8 *remote_client_addr;
uint16 remote_client_port;

View File

@ -902,6 +902,7 @@ NTSTATUS make_external_rpc_pipe(TALLOC_CTX *mem_ctx,
ev_ctx,
socket_np_dir,
pipe_name,
NCACN_NP,
remote_client_address,
NULL, /* client_name */
local_server_address,
@ -1034,6 +1035,7 @@ static struct np_proxy_state *make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx,
subreq = tstream_npa_connect_send(talloc_tos(), ev,
socket_np_dir,
pipe_name,
NCACN_NP,
remote_address,
NULL, /* client_name */
local_address,

View File

@ -330,6 +330,7 @@ static NTSTATUS ipc_open(struct ntvfs_module_context *ntvfs,
ipriv->ntvfs->ctx->event_ctx,
directory,
fname,
NCACN_NP,
remote_client_addr,
NULL,
local_server_addr,