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

Add direct command Injection vulnerability (CWE-77, OWASP API 8) #121

Open
JBAhire opened this issue Oct 4, 2022 · 3 comments
Open

Add direct command Injection vulnerability (CWE-77, OWASP API 8) #121

JBAhire opened this issue Oct 4, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@JBAhire
Copy link
Collaborator

JBAhire commented Oct 4, 2022

Is your feature request related to a problem? Please describe.
Currently, we can use crAPI to demonstrate indirect command injection but we also want to add capabilities to demonstrate direct command injection.

Describe the solution you'd like
@piyushroshan , can you guide us here for a solution?

@JBAhire JBAhire added enhancement New feature or request good first issue Good for newcomers hacktoberfest labels Oct 4, 2022
@afreen23
Copy link

afreen23 commented Oct 8, 2022

Hello,
I am working on a solution for this,

@afreen23
Copy link

Hello @piyushroshan @JBAhire ,
Can we use the api /identity/api/v2/user/videos/convert_video for exposing this vulnerability since it requires to run conversion command in bash ?

return new CRAPIResponse(
bashCommand.executeBashCommand(profileVideo.getConversion_params()), 200);

Though I am not sure what command is passed there ⬆️ . Only params are being passed now:

private String conversion_params = "-v codec h264";

While running on dev mode it kept saying "Failed to convert" since x-forwarded-host headers were missing.

if (xForwardedHost == null) {
if (videoId != null && videoId > 0) {
Optional<ProfileVideo> optionalProfileVideo = profileVideoRepository.findById(videoId);
if (optionalProfileVideo.isPresent() && block_shell_injections) {
profileVideo = optionalProfileVideo.get();
if (ProfileValidator.checkContains(profileVideo.getConversion_params())) {
return new CRAPIResponse(UserMessage.CONVERSION_VIDEO_OK, 200);
} else if (profileVideo.getConversion_params().equalsIgnoreCase("-v codec h264")) {
return new CRAPIResponse(UserMessage.CONVERT_VIDEO_BASH_COMMAND_TRIGGERED, 200);
} else if (!profileVideo.getConversion_params().equalsIgnoreCase("-v codec h264")) {
if (ProfileValidator.checkSpecialCharacter(profileVideo.getConversion_params())) {
return new CRAPIResponse(UserMessage.CONVERT_VIDEO_INTERNAL_ERROR, 500);
}
return new CRAPIResponse(UserMessage.YOU_WON_THE_GAME, 200);
}
return new CRAPIResponse(UserMessage.CONVERT_VIDEO_INTERNAL_ERROR, 500);
} else if (optionalProfileVideo.isPresent()
&& !block_shell_injections
&& optionalProfileVideo.get().getConversion_params() != null) {
profileVideo = optionalProfileVideo.get();
return new CRAPIResponse(
bashCommand.executeBashCommand(profileVideo.getConversion_params()), 200);
}
return new CRAPIResponse(UserMessage.CONVERT_VIDEO_INTERNAL_ERROR, 500);
}
return new CRAPIResponse(UserMessage.CONVERT_VIDEO_PARAM_IS_MISSING, 400);
} else {
return new CRAPIResponse(UserMessage.CONVERT_VIDEO_INTERNAL_USE_ONLY, 403);

I am looking into this but if you have any pointers or other suggestions please guide.
Thanks!

@piyushroshan
Copy link
Collaborator

piyushroshan commented Oct 11, 2022

That's the indirect command injection in crAPI. We can for sure enhance in that direction. Since this is get request maybe provide a query param as conversion param in the get request that can invoke the same pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants