librdkafka icon indicating copy to clipboard operation
librdkafka copied to clipboard

Harmful function call (system). Consider doing `kinit` programmatically

Open filimonov opened this issue 4 years ago • 5 comments

In clickhouse CI, we do checks if there is some usage of glibc function which are considered harmful.

Recently it caught system function call done by librdkafka (firing kinit).

It seems like kinit (getting/refreshing TGT) can be done programmatically: https://github.com/ClickHouse/ClickHouse/issues/27651

Loosely related to https://github.com/edenhill/librdkafka/issues/2709

filimonov avatar Aug 16 '21 14:08 filimonov

Just so I understand, given that the client configuration is controlled by the user, what is the attack vector for system("$kinit ..") ?

edenhill avatar Aug 16 '21 15:08 edenhill

See some reasoning https://github.com/ClickHouse/ClickHouse/issues/27651#issuecomment-899008585

Imagine that RDBMS user (he is not the server admin) can create engine=Kafka tables (internally librdkafka consumers) and control their configuration by DDL. You don't want allowing him to run some binaries on DB server.

P.S. It's not possible in ClickHouse, but illustrate the potential issue: the user who is allowed to create and use as many librdkafka consumers as he need, may not be allowed to run any binaries on the server.

filimonov avatar Aug 16 '21 18:08 filimonov

There's also plugin.library.paths= that can be used to load dynamic libraries.

edenhill avatar Aug 16 '21 19:08 edenhill

We could add something like rd_kafka_conf_disable_unsafe_properties(rd_kafka_conf_t *); that such applications can use to disable any unsafe properties to be set with ..rd_kafka_conf_set(). Would that solve it?

edenhill avatar Apr 08 '22 11:04 edenhill

You can just do the same as kinit does using krb5_ api calls.

BTW: that was fixed inside clickhouse this way: https://github.com/ClickHouse/ClickHouse/pull/38105/files

filimonov avatar Jan 25 '24 09:01 filimonov