Skip to content

Commit cd27bea

Browse files
fix: [UIE-10152] - Fix html injection vuln in open Supprt Ticket and Quotas Increase Form.
1 parent 5f79e44 commit cd27bea

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

packages/manager/src/features/Account/Quotas/QuotasIncreaseForm.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as React from 'react';
1414
import { Controller, FormProvider, useForm } from 'react-hook-form';
1515

1616
import { Markdown } from 'src/components/Markdown/Markdown';
17+
import { SUPPORT_TICKET_SANITIZE_OPTIONS } from 'src/features/Support/sanitizeOptions';
1718

1819
import { getQuotaIncreaseFormSchema, getQuotaIncreaseMessage } from './utils';
1920

@@ -254,7 +255,10 @@ export const QuotasIncreaseForm = (props: QuotasIncreaseFormProps) => {
254255
{summary}
255256
</Typography>
256257
<Markdown textOrMarkdown={quotaIncreaseDescription} />{' '}
257-
<Markdown textOrMarkdown={notes ?? ''} />
258+
<Markdown
259+
sanitizeOptions={SUPPORT_TICKET_SANITIZE_OPTIONS}
260+
textOrMarkdown={notes ?? ''}
261+
/>
258262
</Stack>
259263
</Accordion>
260264
<ActionsPanel

packages/manager/src/features/Support/TicketDetailText.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { makeStyles } from 'tss-react/mui';
77

88
import { Markdown } from 'src/components/Markdown/Markdown';
99

10+
import { SUPPORT_TICKET_SANITIZE_OPTIONS } from './sanitizeOptions';
11+
1012
import type { Theme } from '@mui/material/styles';
1113

1214
const useStyles = makeStyles()((theme: Theme) => ({
@@ -52,7 +54,10 @@ export const TicketDetailText = (props: Props) => {
5254
return (
5355
<Grid className={classes.root} container spacing={2}>
5456
<Grid style={{ width: '100%' }}>
55-
<Markdown textOrMarkdown={ticketReplyBody} />
57+
<Markdown
58+
sanitizeOptions={SUPPORT_TICKET_SANITIZE_OPTIONS}
59+
textOrMarkdown={ticketReplyBody}
60+
/>
5661
</Grid>
5762
{truncatedText !== text && (
5863
<IconButton
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import type { SanitizeOptions } from 'src/utilities/sanitizeHTML';
2+
3+
/**
4+
* Centralized sanitization configuration for support ticket content
5+
*
6+
* This configuration is used when rendering user-submitted support ticket descriptions
7+
* and replies via the Markdown component. It allows safe Markdown formatting while
8+
* blocking dangerous HTML that could be used for phishing attacks.
9+
*
10+
* Security Policy:
11+
* - Allows: Bold, italic, lists, code blocks, headers, tables, etc. (safe formatting)
12+
* - Blocks: <a> tags and other potentially dangerous HTML elements
13+
* - Preserves: Text content when removing disallowed tags
14+
*
15+
* Rationale:
16+
* - Users expect Markdown formatting support for better readability
17+
* - Links are blocked to prevent phishing/social engineering attacks
18+
* - Sanitization happens at render time (not on submit) to preserve original content
19+
*/
20+
export const SUPPORT_TICKET_SANITIZE_OPTIONS: SanitizeOptions = {
21+
ALLOWED_TAGS: [
22+
// Text formatting
23+
'strong',
24+
'b',
25+
'em',
26+
'i',
27+
'u',
28+
'del',
29+
's',
30+
// Code blocks
31+
'code',
32+
'pre',
33+
'span',
34+
// Lists
35+
'ul',
36+
'ol',
37+
'li',
38+
// Structure
39+
'p',
40+
'br',
41+
'hr',
42+
'blockquote',
43+
// Headers
44+
'h1',
45+
'h2',
46+
'h3',
47+
'h4',
48+
'h5',
49+
'h6',
50+
// Tables
51+
'table',
52+
'thead',
53+
'tbody',
54+
'tr',
55+
'th',
56+
'td',
57+
// NO <a> tags - links are blocked to prevent phishing
58+
],
59+
ALLOWED_ATTR: ['class', 'style'], // Only for syntax highlighting in code blocks
60+
KEEP_CONTENT: true, // Preserve text when removing disallowed tags
61+
};

0 commit comments

Comments
 (0)