Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow command arguments in schedule #635

Merged
merged 4 commits into from
Apr 14, 2023
Merged

Allow command arguments in schedule #635

merged 4 commits into from
Apr 14, 2023

Conversation

recursivetree
Copy link
Contributor

This pr allows you to add a command with argument to the seat command schedule.
fixes eveseat/seat#867.

@leonjza
Copy link
Member

leonjza commented Nov 14, 2022

How do we prevent OS command injections here without validating the arguments? It's the primary reason I never added support for it.

@recursivetree
Copy link
Contributor Author

these aren't os level commands, these are just artisan commands. And second, if you have access to use the endpoint, you are an admin. In this case, you can probably access the OS anyways

@leonjza
Copy link
Member

leonjza commented Nov 15, 2022

Being an administrator on SeAT does not (and should not) mean you are an OS administrator.

A quick dig again through some of the internals of \Illuminate\Console\Application and \Symfony\Component\Console\Application to see how commands are dispatched has me think that if we have unfiltered arguments, adding something like ;id or similar to a command as argument would result in shell expansion getting you arbitrary code execution.

I'm curious enough to PoC this soon actually :)

@recursivetree
Copy link
Contributor Author

I have been browsing through the code a bit and I haven't found what you mean with ;id, but I think i found a way to check if all required parameters are supplied.

@leonjza
Copy link
Member

leonjza commented Nov 15, 2022

Alright I spent a few minutes on this and a face value it seems like I am wrong. Wrote a simple command like this:

// app/Console/Commands/ArgPoc.php
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class ArgPoc extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'poc:args {argname}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Argument Injection POC';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
	Log::info('running command with args: ' . $this->argument('argname'));

        return Command::SUCCESS;
    }
}

And a simple route like this:

// routes/web.php
Route::get('/poc/{args}', function($args) {
    $exitCode = Artisan::call('poc:args ' . $args);
    return $exitCode;
});

Injecting a command via the URL as a test seems to have no effect :)

http://172.16.182.175:8000/poc/`whoami`

command arguments in schedule

styleci+comments
command arguments in schedule

styleci+comments
@recursivetree recursivetree changed the base branch from master to 5.0.x March 28, 2023 13:41
@recursivetree
Copy link
Contributor Author

I updated this PR for seat 5

@warlof warlof merged commit 7ca75e3 into eveseat:5.0.x Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request - Cron schedule - Allow command argument entry
3 participants