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

Upgrade xml2js to address security vulnerability #22080

Closed
wants to merge 1 commit into from
Closed

Upgrade xml2js to address security vulnerability #22080

wants to merge 1 commit into from

Conversation

karlhorky
Copy link
Contributor

Why

Address security vulnerability in xml2js below version 0.5.0

Ref: Leonidas-from-XIV/node-xml2js#663 (comment)

How

Upgrade xml2js version

Test Plan

Checklist

@karlhorky
Copy link
Contributor Author

karlhorky commented Apr 11, 2023

Ah, seems maybe this is already done by the bot over here:

@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against fb7efb6

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Apr 11, 2023
@Simek
Copy link
Collaborator

Simek commented Apr 11, 2023

Hello @karlhorky, thank you for preparing a bump PR! 👍 Unfortunately, it looks like some tests are failing after the package upgrade:

Would you like to look at the failures and try to find the root cause of that? Maybe there were some breaking changes in new version, besides the vulnerability fix, since they have bumped the minor?

@tambor81
Copy link

tambor81 commented Apr 12, 2023

is anybody looking at these failing tests?
the fix seems to be good on xml2js on 0.5.0 but the vulnerability is still failing in our daily builds

@rikur
Copy link

rikur commented Apr 30, 2023

Could this be addressed? Using resolutions to fix the vulnerability (which will trigger a pentest failure) breaks expo-plugins:

TypeError: [android.manifest]: withAndroidManifestBaseMod: androidManifest.manifest.hasOwnProperty is not a function

@EvanBacon

@brentsmyth
Copy link

brentsmyth commented May 19, 2023

It seems a primary change in xml2js 0.5.0 was to start using Object.create(null); vs {} to resolve a CVE where properties like __proto__ or hasOwnProperty could be passed via the XML. If any logic is relying on these traditional JS properties (which looks to be the case) then it would need cleaning up.

See: Leonidas-from-XIV/node-xml2js#603

@brentsmyth
Copy link

It appears that many tests are failing because they parse XML to JS objects (with null prototype) and then feed those objects back through logic like this which expects properties like isString:

} else if (manifest.toString) {
const builder = new Builder({
headless: true,
});
// For strings.xml
if (Array.isArray(manifest?.resources?.string)) {
for (const string of manifest?.resources?.string) {
if (string.$.translatable === 'false' || string.$.translatable === false) {
continue;
}
string._ = escapeAndroidString(string._);
}
}
xmlInput = builder.buildObject(manifest);
return xmlInput;

Might be a bit tricky to fix this without pulling some things apart. Possibly might also be worth considering an alternative like https://github.com/NaturalIntelligence/fast-xml-parser. They seemed to have recently addressed the issue in a slightly more pragmatic manner ... NaturalIntelligence/fast-xml-parser@2b032a4

@brentvatne
Copy link
Member

we use xml2js@0.6.0 now, thanks for the PR though! sorry i didn't follow up here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: suggestions ExpoBot has some suggestions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants