Skip to content

Commit d82c7b5

Browse files
authored
Add admin signature validation in RsGenExchange
It is possible to fool Retroshare into accepting a group without verification by creating one that has no signature at all (no admin signature and no author signature). Now it will check the admin signature for every new group, not just group updates.
1 parent 36651e5 commit d82c7b5

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

src/gxs/rsgenexchange.cc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,10 +1114,42 @@ int RsGenExchange::validateGrp(RsNxsGrp* grp)
11141114
}
11151115

11161116
if(idValidate)
1117+
{
1118+
// Validate admin signature
1119+
RsTlvSecurityKeySet keys = metaData.keys;
1120+
GxsSecurity::createPublicKeysFromPrivateKeys(keys);
1121+
std::map<RsGxsId, RsTlvPublicRSAKey>& public_keys = keys.public_keys;
1122+
std::map<RsGxsId, RsTlvPublicRSAKey>::iterator keyMit = public_keys.find(RsGxsId(metaData.mGroupId));
1123+
1124+
if(keyMit == public_keys.end())
1125+
{
1126+
#ifdef GEN_EXCH_DEBUG
1127+
std::cerr << "RsGenExchange::validateGrp() admin key not found! " << std::endl;
1128+
#endif
1129+
return VALIDATE_FAIL;
1130+
}
1131+
1132+
std::map<SignType, RsTlvKeySignature>& signSet = metaData.signSet.keySignSet;
1133+
std::map<SignType, RsTlvKeySignature>::iterator mit = signSet.find(INDEX_AUTHEN_ADMIN);
1134+
if(mit == signSet.end())
1135+
{
1136+
#ifdef GEN_EXCH_DEBUG
1137+
std::cerr << "RsGenExchange::validateGrp() admin sign not found! " << std::endl;
1138+
std::cerr << "RsGenExchange::validateGrp() grpId: " << metaData.mGroupId << std::endl;
1139+
#endif
1140+
return VALIDATE_FAIL;
1141+
}
1142+
RsTlvKeySignature adminSign = mit->second;
1143+
if (!GxsSecurity::validateNxsGrp(*grp, adminSign, keyMit->second))
1144+
{
1145+
return VALIDATE_FAIL;
1146+
}
11171147
return VALIDATE_SUCCESS;
1148+
}
11181149
else
1150+
{
11191151
return VALIDATE_FAIL;
1120-
1152+
}
11211153
}
11221154

11231155
bool RsGenExchange::checkAuthenFlag(const PrivacyBitPos& pos, const uint8_t& flag) const

0 commit comments

Comments
 (0)