Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/vendor-dashboard/layout/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const Sidebar = ( {
href={ siteUrl || '/' }
className={ twMerge(
'flex items-center gap-3.5 min-h-20 no-underline focus:!outline-none rounded-md',
collapsed ? 'px-5 justify-center' : 'px-8',
collapsed ? 'px-5 justify-center' : 'px-8'
) }
>
{ siteIcon ? (
Expand Down Expand Up @@ -312,7 +312,9 @@ const Sidebar = ( {
item?.menu_manager_title || item?.title,
item
) as string;
const isMenuItemActive = isParentActive || isParentActiveCollapsed ;
const isMenuItemActive =
isParentActive ||
isParentActiveCollapsed;

return (
<li
Expand Down Expand Up @@ -351,10 +353,16 @@ const Sidebar = ( {
? 'w-0 max-w-0'
: 'w-10 max-w-10 justify-center'
: 'text-sm px-3',
(isMenuItemActive) &&
'active'
isMenuItemActive && 'active'
) }
data-active={ isMenuItemActive ? 'true' : 'false' }
data-active={
isMenuItemActive
? 'true'
: 'false'
}
target={
item.target || '_self'
}
Comment on lines +363 to +365

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.

⚠️ Potential issue | 🟠 Major

Add rel="noopener noreferrer" when target may be _blank.

Now that target is driven by config (item.target / subitem.target), any value of _blank (or a named window) will open a new browsing context that can access window.opener and trigger reverse tabnabbing / referrer leakage. Since the nav config may be filterable/extensible, treat these as untrusted.

Apply the same fix to the submenu anchor at lines 492–495.

🛡️ Proposed fix
                                                 target={
                                                     item.target || '_self'
                                                 }
+                                                rel={
+                                                    item.target === '_blank'
+                                                        ? 'noopener noreferrer'
+                                                        : undefined
+                                                }

And for the submenu:

                                                                             target={
                                                                                 subitem.target ||
                                                                                 '_self'
                                                                             }
+                                                                            rel={
+                                                                                subitem.target ===
+                                                                                '_blank'
+                                                                                    ? 'noopener noreferrer'
+                                                                                    : undefined
+                                                                            }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
target={
item.target || '_self'
}
target={
item.target || '_self'
}
rel={
item.target === '_blank'
? 'noopener noreferrer'
: undefined
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/vendor-dashboard/layout/components/Sidebar.tsx` around lines 363 - 365,
The link rendering in Sidebar.tsx currently sets target from item.target /
subitem.target (e.g., the anchor using target={item.target || '_self'} and the
submenu anchor at the later block), which can open untrusted browsing contexts;
update both anchors to include rel="noopener noreferrer" whenever the computed
target may open a new context (e.g., target === '_blank' or any target not equal
to '_self' / when item.target/subitem.target is truthy and not '_self').
Concretely: compute the effective target (target = item.target || '_self' /
subTarget = subitem.target || '_self') and set rel to 'noopener noreferrer' when
that target is '_blank' or otherwise not '_self', then pass rel={computedRel}
into both anchor elements.

>
{ /* Icon: turn white when its popover is visible */ }
<span
Expand Down Expand Up @@ -481,6 +489,10 @@ const Sidebar = ( {
isSubActive &&
'active'
) }
target={
subitem.target ||
'_self'
}
>
<LucideIcons.Settings className="w-5 h-5 !text-transparent" />
<span className="ml-2">
Expand Down
Loading