-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: XSS vulnerability with prototype pollution on AST * test: add e2e test for scurity fix * fix: update e2e * fix: filename * fix: change type name
- Loading branch information
Showing
8 changed files
with
839 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { getText } from './helper' | ||
|
||
describe('CVE-2024-52809', () => { | ||
beforeAll(async () => { | ||
await page.goto(`http://localhost:8080/e2e/hotfix/CVE-2024-52809.html`) | ||
}) | ||
|
||
test('fix', async () => { | ||
expect(await getText(page, 'p')).toMatch('hello world!') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>vue-i18n XSS</title> | ||
<script src="../../node_modules/vue/dist/vue.global.js"></script> | ||
<script src="../../packages/vue-i18n/dist/vue-i18n.global.js"></script> | ||
<!-- Scripts that perform prototype contamination, such as being distributed from malicious hosting sites or injected through supply chain attacks, etc. --> | ||
<script> | ||
/** | ||
* Prototype pollution vulnerability with `Object.prototype`. | ||
* The 'static' property is part of the optimized AST generated by the vue-i18n message compiler. | ||
* About details of special properties, see https://github.com/intlify/vue-i18n/blob/master/packages/message-compiler/src/nodes.ts | ||
* | ||
* In general, the locale messages of vue-i18n are optimized during production builds using `@intlify/unplugin-vue-i18n`, | ||
* so there is always a property that is attached during optimization like this time. | ||
* But if you are using a locale message AST in development or your own, there is a possibility of XSS if a third party injects prototype pollution code. | ||
*/ | ||
Object.defineProperty(Object.prototype, 'static', { | ||
configurable: true, | ||
get() { | ||
alert('prototype polluted!') | ||
return 'prototype pollution' | ||
} | ||
}) | ||
</script> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
<p>{{ t('hello') }}</p> | ||
</div> | ||
<script> | ||
const { createApp } = Vue | ||
const { createI18n, useI18n } = VueI18n | ||
|
||
// AST style locale message, which build by `@intlify/unplugin-vue-i18n` | ||
const en = { | ||
hello: { | ||
type: 0, | ||
body: { | ||
items: [ | ||
{ | ||
type: 3, | ||
value: 'hello world!' | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
const i18n = createI18n({ | ||
legacy: false, | ||
locale: 'en', | ||
messages: { | ||
en | ||
} | ||
}) | ||
|
||
const app = createApp({ | ||
setup() { | ||
const { t } = useI18n() | ||
return { t } | ||
} | ||
}) | ||
app.use(i18n) | ||
app.mount('#app') | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.