Skip to content

Fix external entities vulnerability - #35

Merged
ellieayla merged 2 commits into
salesforce-python-client:masterfrom
KevinHock:fix_xml_security
Nov 22, 2017
Merged

ellieayla merged 2 commits into
salesforce-python-client:masterfrom
KevinHock:fix_xml_security

Conversation

@KevinHock

Copy link
Copy Markdown
Contributor

So in xmltramp it uses a library called xml.sax
https://github.com/alanjcastonguay/pyforce/blob/master/src/pyforce/xmltramp.py#L5

So the xml sax library is one of only 2 libraries vulnerable to XML External Entity Expansion
(https://docs.python.org/2/library/xml.html#xml-vulnerabilities)
If Salesforce gets compromised or has a rogue employee they can probe the network using it and send requests to anything, potentially getting remote code execution. For more information about XXE visit https://en.wikipedia.org/wiki/XML_external_entity_attack

Comment thread setup.py
from setuptools import setup

setup(name='pyforce',
version='1.7.3', # be sure to update the version in pyforce.py too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Didn't see any version number in pyforce.py, let me know if I missed something @alanjcastonguay

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's no longer true. And you removed the comment as part of your change. Awesome~

Comment thread requirements.txt Outdated
@@ -0,0 +1 @@
defusedxml==0.5.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if you want a requirements.txt, thoughts @alanjcastonguay?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sure.

Comment thread setup.py Outdated
setup(name='pyforce',
version='1.7.3', # be sure to update the version in pyforce.py too
version='1.8.0',
install_requires=['defusedxml==0.5.0'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This specific version, or anything higher than it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, added defusedxml>=0.5.0

@ellieayla ellieayla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can (should?) you make this a version range, for anything that doesn't break major compatibility?

@ellieayla

Copy link
Copy Markdown
Contributor

I acknowledge that Salesforce can be the attacking party here. But is the vector you're concerned about some untrusted party submitting stuff to Salesforce, and then this library reading it back out?

@KevinHock

Copy link
Copy Markdown
Contributor Author

I'm not sure what you mean by "version range", can you elaborate? I'm not that experienced w/ PyPi versioning.
(If it's related, I bumped up the minor version and not the patch version b/c of the new requirement.)

@ellieayla

Copy link
Copy Markdown
Contributor

I'm not sure what you mean by "version range", can you elaborate? I'm not that experienced w/ PyPi versioning.

install_requires=['defusedxml>=0.5.0'],

That's what I meant.

@ellieayla
ellieayla merged commit d69a73c into salesforce-python-client:master Nov 22, 2017
@KevinHock

KevinHock commented Nov 22, 2017 •

Copy link
Copy Markdown
Contributor Author

I acknowledge that Salesforce can be the attacking party here. But is the vector you're concerned about some untrusted party submitting stuff to Salesforce, and then this library reading it back out?

I'm just concerned about Salesforce being compromised/rogue employee, I know a few people that work there (security people) and they're great, but if e.g a developer said they wanted to take a response from even Google and put it into subprocess.check_call I'd be a little worried about it. The sax processor is arguably equivalent b/c of how vuln it is.

@ellieayla

ellieayla commented Nov 22, 2017 •

Copy link
Copy Markdown
Contributor

Then I agree with your assessment and remediation. Thanks for the fix.

@KevinHock

Copy link
Copy Markdown
Contributor Author

Oh okay, awesome @alanjcastonguay 👍 Great OSS experience!

@KevinHock

Copy link
Copy Markdown
Contributor Author

@alanjcastonguay Would you be okay with putting the latest (1.8.0) up on https://pypi.python.org/pypi/pyforce?

Cheers.

@ellieayla

ellieayla commented Dec 1, 2017 •

Copy link
Copy Markdown
Contributor

Tagged commit d69a73c as 1.8.0: https://pypi.python.org/pypi/pyforce/1.8.0

@KevinHock
KevinHock deleted the fix_xml_security branch December 1, 2017 02:48
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