Skip to content

Commit

Permalink
Don't compile dangerous commands in client
Browse files Browse the repository at this point in the history
A server can execute commands on the client via stufftext. Therefore, a
malicious server can perform evil operations. To limit the attack
vector, the following commands have been disabled in the client:

- chmod
- localcommand
- ls
- nslookup
- rm
- rmdir
- script
  • Loading branch information
osm authored and qqshka committed Mar 4, 2024
1 parent 97a8468 commit f2473c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sv_ccmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,9 @@ void SV_InitOperatorCommands (void)
for (i = MIN_LOG; i < MAX_LOG; ++i)
Cmd_AddCommand (logs[i].command, logs[i].function);

#ifdef SERVERONLY
Cmd_AddCommand ("nslookup", SV_Nslookup_f);
#endif
Cmd_AddCommand ("check_maps", SV_Check_maps_f);
Cmd_AddCommand ("snap", SV_Snap_f);
Cmd_AddCommand ("snapall", SV_SnapAll_f);
Expand All @@ -1838,23 +1840,27 @@ void SV_InitOperatorCommands (void)
Cmd_AddCommand ("status", SV_Status_f);
Cmd_AddCommand ("sv_status", SV_Status_f);

#ifdef SERVERONLY
//bliP: init ->
Cmd_AddCommand ("rmdir", SV_RemoveDirectory_f);
Cmd_AddCommand ("rm", SV_RemoveFile_f);
Cmd_AddCommand ("ls", SV_ListFiles_f);
#endif

Cmd_AddCommand ("mute", SV_Mute_f);
Cmd_AddCommand ("cuff", SV_Cuff_f);

Cmd_AddCommand ("penaltylist", SV_ListPenalty_f);
Cmd_AddCommand ("penaltyremove", SV_RemovePenalty_f);

#ifdef SERVERONLY
#ifndef _WIN32
Cmd_AddCommand ("chmod", SV_ChmodFile_f);
#endif //_WIN32
//<-
if (SV_CommandLineEnableLocalCommand())
Cmd_AddCommand ("localcommand", SV_LocalCommand_f);
#endif

Cmd_AddCommand ("map", SV_Map_f);
#ifdef SERVERONLY
Expand Down
2 changes: 2 additions & 0 deletions src/sv_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,9 @@ void SV_MVDInit(void)
Cmd_AddCommand ("sv_demoinfo", SV_MVDInfo_f);
Cmd_AddCommand ("sv_demoembedinfo", SV_MVDEmbedInfo_f);
// not prefixed.
#ifdef SERVERONLY
Cmd_AddCommand ("script", SV_Script_f);
#endif

Cmd_AddCommand ("sv_usercmdtrace", SV_UserCmdTrace_f);

Expand Down

0 comments on commit f2473c5

Please sign in to comment.