A cookie banner with no Reject button: what a release check should catch
A consent banner is the first thing every visitor sees, and it is the one place where a privacy choice gets made. If the banner shows "Accept all" as a large button and hides refusing in a settings menu, the visitor has
A consent banner is the first thing every visitor sees, and it is the one place where a privacy choice gets made. If the banner shows "Accept all" as a large button and hides refusing in a settings menu, the visitor has not really chosen anything. The French data protection regulator, CNIL, has fined companies over banners that made refusing harder than accepting. The fine is the expensive part, and the fix is often one extra button.
Zelsis runs two checks on pull requests for cookie and consent code. Both are flagged at medium severity. Neither fails the check on its own, but both show up in the pull request comment before the banner ships.
1. A banner with an Accept button and no way to refuse
The check looks at files that define a banner. A file counts when its path contains cookie-banner, consent-banner, consent-modal or cookie-consent, or when it declares a component named like CookieBanner or ConsentModal. Inside that file, the check flags the banner when it finds an accept control (a button labelled Accept, Allow, Agree or I agree) and no decline wording such as reject, decline, opt out, refuse, deny, necessary only or essential only.
This one is flagged:
// components/CookieBanner.tsx
export function CookieBanner({ acceptAll }: { acceptAll: () => void }) {
return (
<div className="cookie-banner">
<p>We use cookies to improve your experience.</p>
<button onClick={acceptAll}>Accept all</button>
</div>
);
}
This one passes, because the same file now has a reject button:
<button onClick={rejectAll}>Reject all</button>
<button onClick={acceptAll}>Accept all</button>
Give both buttons the same size, weight and contrast. The check only confirms that the words are present. It cannot judge how the buttons look, so a person still needs to look at the screen.
The check reads one file, so it has a blind spot. If the reject button sits in a child component in another file, the banner file can still be flagged. Treat that finding as a question to answer, not as a verdict.
2. A consent cookie that lasts longer than 13 months
A consent choice should not last forever. CNIL guidance limits how long a consent choice can last to 13 months, after which the site should ask again. The check looks at cookie-setting calls whose name contains consent, cc_cookie, optanon, cookie_pref or gdpr. If the lifetime is longer than 396 days, it flags the line.
Flagged, in Express (where maxAge is in milliseconds):
res.cookie('cookie_consent', 'rejected', {
maxAge: 400 * 24 * 60 * 60 * 1000, // 400 days: flagged
});
Passes, at 365 days:
res.cookie('cookie_consent', 'rejected', {
maxAge: 365 * 24 * 60 * 60 * 1000,
});
What these checks do not prove
A pass means these two patterns are absent. It does not mean the banner is compliant. Compliance also depends on what loads before the visitor chooses, what the privacy page says, and how long the data is kept. Those need their own review.
To see where your banner stands, count the clicks it takes to refuse. If the answer is more than one, start there.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.