Why are some commands blocked in Matlab Grader, e.g. system?

6 次查看(过去 30 天)
When a Matlab Grader user uses certain commands in the solution, e.g.
path
system
then an error is returned:
Error: You may not use the command(s) path, system in your code

回答(1 个)

colordepth
colordepth 2024-12-20
编辑:colordepth 2024-12-20
MATLAB Grader restricts certain commands for the purpose of cheating prevention and security reasons. These commands can alter the system environment or execute system-level tasks, which could lead to potential misuse or unintended side effects.
For a related discussion on command restrictions in MATLAB Grader, see https://www.mathworks.com/matlabcentral/answers/2083228-the-run-command-does-not-work-in-garder.
  1 个评论
Piotr Kot
Piotr Kot 2024-12-20
编辑:Piotr Kot 2024-12-20
I understand that this was the original intention. But it seems to me that it turned out as usual: Every user of the Matlab Grader system can run the system or run command, for example, in this way:
fprintf(fopen('try1.m','w'),"%s","system('ls -la')")
try1
Output:
ans =
16
total 24
drwxr-xr-x 2 matlab matlabgroup 4096 Dec 20 12:21 .
drwx------ 3 matlab matlabgroup 4096 Dec 20 12:20 ..
-rw-r--r-- 1 matlab matlabgroup 24 Dec 20 12:21 ScoringEngineSharedVariable1.m
-rw-r--r-- 1 matlab matlabgroup 57 Dec 20 12:21 solution.m
-rw-r--r-- 1 matlab matlabgroup 31 Dec 20 12:21 solutionTest.m
-rw-r--r-- 1 matlab matlabgroup 16 Dec 20 12:21 try1.m
ans =
0
Moreover, the Matlab Grader team commented the above code in the following way:
„The behavior explained through the reproduction steps is intended. The MATLAB session running within Grader operates within an isolated containerized instance. Logged-in users are permitted to run MATLAB functions, including commands that interact programmatically with the operating system and the MATLAB application. Therefore, executing the 'system' command does not introduce any additional risk to MATLAB Grader."
And in this situation I completely do not understand why attempts were made to block anything at all.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Use Content in an LMS Course 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by