Skip to content

Commit 2a41d0a

Browse files
klemens-morgensternKlemens Morgenstern
authored andcommitted
batch file execution is forbidden by default
1 parent dc00bf8 commit 2a41d0a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/boost/process/v2/windows/default_launcher.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ struct default_launcher
225225
INVALID_HANDLE_VALUE,
226226
INVALID_HANDLE_VALUE},
227227
nullptr};
228+
/// Allow batch files to be executed, which might pose a security threat.
229+
bool allow_batch_files = false;
230+
228231
/// The process_information that gets assigned after a call to CreateProcess
229232
PROCESS_INFORMATION process_information{nullptr, nullptr, 0,0};
230233

@@ -293,6 +296,12 @@ struct default_launcher
293296
Args && args,
294297
Inits && ... inits ) -> enable_init<Executor, Inits...>
295298
{
299+
if (!allow_batch_files && ((executable.extension() == ".bat") || (executable.extension() == ".cmd")))
300+
{
301+
BOOST_PROCESS_V2_ASSIGN_EC(ec, ERROR_ACCESS_DENIED, system_category());
302+
return basic_process<Executor>(exec);
303+
}
304+
296305
auto command_line = this->build_command_line(executable, std::forward<Args>(args));
297306

298307
ec = detail::on_setup(*this, executable, command_line, inits...);

0 commit comments

Comments
 (0)