rc-util's getScrollBarSize Does Not Respect ConfigProvider's csp.nonce, Causing CSP Violations
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- react, typescript
Research direction
Start by reading src/getScrollBarSize.tsx around line 49 and trace how its updateCSS call is reached when rc-table uses getScrollBarSize. Check how the ConfigProvider csp nonce is made available to this utility. Done means the injected scrollbar-measurement style uses the configured nonce and no longer causes the reported CSP violation.
Written by the indexing model from the issue text.
Description
The getScrollBarSize function in rc-util dynamically injects CSS using updateCSS for measuring scrollbar size. However, it does not respect the nonce value provided via the ConfigProvider's csp property. This leads to CSP violations in environments with strict style-src policies.
Steps to Reproduce
- Set up a project using
antdwith aConfigProviderconfigured to include anoncevalue:<ConfigProvider csp={{ nonce: 'test-nonce', }} > - Use a component that indirectly triggers the
getScrollBarSizefunction (i.e.Tablefromrc-table) - Observe CSP violations in the browser console, such as:
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'nonce-test-nonce'".
Expected Behavior
The getScrollBarSize function should respect the configured nonce by passing it to the updateCSS function when dynamically injecting styles.
Affected Code
The relevant part of the getScrollBarSize.tsx, line 49:
updateCSS(
`
#${randomId}::-webkit-scrollbar {
${widthStyle}
${heightStyle}
}`,
randomId,
);
Additional info
This issue was first introduced in the following commit: Commit Hash: e96b0c6
- Dominant language
- TypeScript
- Stars
- 670
- Forks
- 205
- Avg merge
- 15d 17h
- Merged PRs (30d)
- 6
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from react-component/util
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
react-component/util#816 ·
-
injectCSS method not attaching csp nonce passed to it. it is used in antd components internally Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
react-component/util#671 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
react-component/util#738 · 1 comment · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
react-component/util#710 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
react-component/util#647 · 5 comments ·
All issues in react-component/util
Similar issues
-
Browser Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
getsentry/sentry-javascript#24577 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
agilepathway/label-checker#640 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
agentic-workflows
Difficulty 1/5 Under an hour Newbie friendliness 85/100
githubnext/rig#534 ·
-
automation missing-model model-sync provider:pioneer
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
anomalyco/models.dev#7701 ·