// Probe: three independent databases (victim, attacker, reader). The attacker picks // aliases that render exactly like the victim's public ID ("uid" mode shows the first // 8 hex of the fingerprint) and like a genuinely anonymous post. The reader's backend // accepts them all; the feed shows them identically (see tst_probe_spoof.qml). #include "../../src/native/backend/ForumBackend.h" #include #include #include #include #include #include #include static QJsonObject call(ForumBackend &b, QJsonObject o) { return QJsonDocument::fromJson(b.dispatch(QString::fromUtf8(QJsonDocument(o).toJson(QJsonDocument::Compact))).toUtf8()).object(); } static QString shown(const QJsonObject &p) { // Main.qml authorName() const auto m = p["mode"].toString(); return m == "anonymous" ? "Anonymous" : m == "uid" ? p["author"].toString().left(8) : p["author"].toString(); } int main(int argc, char **argv) { QGuiApplication app(argc, argv); QTemporaryDir dv, da, dr; qputenv("LOGOS_FORUM_DATA_DIR", dv.path().toUtf8()); ForumBackend victim; qputenv("LOGOS_FORUM_DATA_DIR", da.path().toUtf8()); ForumBackend attacker; qputenv("LOGOS_FORUM_DATA_DIR", dr.path().toUtf8()); ForumBackend reader; // Victim posts under their public ID. call(victim, {{"op","settings"},{"mode","uid"}}); auto v = call(victim, {{"op","post"},{"board","general"},{"title","Release notes"},{"body","Signed by me."}}); auto vwire = call(victim, {{"op","wire"},{"id",v["id"]}})["wire"].toString(); const auto victimUid = QJsonDocument::fromJson(vwire.toUtf8()).object()["payload"].toObject()["author"].toString(); // Attacker: alias equal to the victim's displayed ID, and alias "Anonymous". QStringList wires; for (const auto &alias : {victimUid.left(8), QString("Anonymous")}) { call(attacker, {{"op","identity"},{"alias",alias}}); call(attacker, {{"op","settings"},{"mode","alias"}}); auto a = call(attacker, {{"op","post"},{"board","general"},{"title","Release notes (" + alias + ")"},{"body","Please install this other build."}}); wires << call(attacker, {{"op","wire"},{"id",a["id"]}})["wire"].toString(); } // A genuinely anonymous post for comparison. call(attacker, {{"op","settings"},{"mode","anonymous"}}); auto an = call(attacker, {{"op","post"},{"board","general"},{"title","Real anonymous"},{"body","x"}}); wires << call(attacker, {{"op","wire"},{"id",an["id"]}})["wire"].toString(); wires.prepend(vwire); for (const auto &w : wires) { auto r = call(reader, {{"op","receive"},{"wire",w}}); const auto p = QJsonDocument::fromJson(w.toUtf8()).object()["payload"].toObject(); std::printf("receive ok=%d mode=%-9s feed shows author as %-10s (tooltip adds: %s)\n", r["ok"].toBool(), qPrintable(p["mode"].toString()), qPrintable(shown(p)), p["mode"].toString()=="alias" ? "alias + ' ยท ' + real fingerprint prefix" : "nothing"); } std::printf("RESULT: an alias equal to the victim's 8-hex ID and an alias 'Anonymous' are accepted and rendered identically to a real UID / anonymous post in the feed.\n"); return 0; }