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

Restrict write18 #40

Merged
merged 8 commits into from
Jan 23, 2018
Merged

Restrict write18 #40

merged 8 commits into from
Jan 23, 2018

Conversation

ian-r-rose
Copy link
Member

It looks like most LaTeX distributions disable write18 by default, so the security risk for arbitrary code execution is already mitigated by that. This exposes an option for making that behavior explicit.

@mpacer
Copy link
Member

mpacer commented Jan 18, 2018

Some notes from talking with @ian-r-rose in person:

I think this should have three values that are strings validated by traitlets. I'm not entirely sure what the string values should be… but I think that we should have restricted write18 enabled as the default; that should probably be called "restricted", and could maybe call the complete enabled option "allow_all", and the completely disabled option as "disabled"?

The way I think we're supposed to do this is to have a Unicode type traitlet, but have a validation function (using a @validate('allow_shell_escape') decorator, see validation) that checks for the values of the string and ensures its only one of those three values. There might be a better way to do that, but that's what first comes to mind.

@ian-r-rose
Copy link
Member Author

This is ready for another look.

Copy link
Member

@mpacer mpacer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes the shell command harder to follow, can we keep it so we don’t need to conditionally add something and then finish the command? Or that we always add the empty string?

if escape_flag != '':
full_latex_sequence.append(escape_flag)

full_latex_sequence.append(f"{tex_base_name}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think I like this… I’d prefer for us to have the literal construction occur in one place and pass in the value even if it were to be the default anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The subprocess failed if it had an empty string in it (for some unknown reason). This is a workaround for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a value to pass in for restricted?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a value to pass in for restricted?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that is the default.

@ian-r-rose
Copy link
Member Author

Fixed.

@mpacer
Copy link
Member

mpacer commented Jan 23, 2018

Does --shell-restricted work for you?

@ian-r-rose
Copy link
Member Author

It does not appear to have any effect. Since restricted mode is default, it preserves that. Is that documented anywhere?

escape_flag = '-no-shell-escape'
elif c.shell_escape == 'restricted':
escape_flag = '-shell-restricted'
full_latex_sequence = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we go back to this being a tuple?

@mpacer mpacer merged commit 1b34d82 into jupyterlab:master Jan 23, 2018
@mpacer mpacer changed the title Disable write18 Restrict write18 Jan 23, 2018
@mpacer mpacer mentioned this pull request Jan 23, 2018
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

Successfully merging this pull request may close these issues.

2 participants