Presented by Andrei Zissu at Core C++ 2022.
Can your code have logging entries whose sensitive messages don't show up in the shipped binaries? And can the following code snippet ever work?
static bool initially_false = false;
void no_one_calls_me() { DO_ON_INIT(initially_false = true); }
int main() {
assert(initially_false == true);
return 0;
}
Well yes, this is actual working C++17 code! And yes, we can use this tool to produce a logger with vanishing strings!
As part of this talk we will go behind the scenes of the DO_ON_INIT utility, the process involved in developing the idea and its surprisingly simple implementation details (under 20 lines of C++17 code, and even less in C++20).
We shall also see how this utility is instrumental in making possible the no-strings-attached logger and its associated automatically-generated decoding facility. We will implement a simple obfuscation technique which replaces logged strings with hashes at compile-time, to avoid shipping binaries containing sensitive textual giveaways. To decode such logs (in a separate decoder utility) we shall use DO_ON_INIT to automatically collect and register all the logged strings system-wide, along with their hashes, without requiring any additional tool (such as an in-house pre-processor).
This is yet another example of emergent behavior in C++, consisting of unrelated language features being put to use together in a novel and unexpected way. Could your idea be next?
-----
Andrei Zissu is a veteran cross-industry C++ developer, notably having worked on low-level reverse engineering systems employing API hooking, DLL injection and other advanced techniques. He is currently employed at Binah.ai, an Israeli startup developing ground breaking AI-based remote health monitoring technology. Recently he has joined the WG21 standards committee as a member of the Israeli NB.