Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

PostgreSQL returns 'f' for boolean false, which PHP casts to true via (bool)'f', causing unverified accounts to bypass email verification checks.

Changes

  • Replace naive (bool) cast with explicit normalization in mapRowToUser()
  • Check if value is already boolean, otherwise test against truthy string list: ['1', 'true', 't', 'yes', 'on']
  • Default to false for all other values including PostgreSQL's 'f'
// Before - vulnerable to PostgreSQL 'f' strings
'email_verified' => (bool)$row['email_verified'],

// After - explicit normalization
$emailVerifiedRaw = $row['email_verified'] ?? null;
$emailVerified = is_bool($emailVerifiedRaw)
    ? $emailVerifiedRaw
    : in_array(strtolower((string)$emailVerifiedRaw), ['1', 'true', 't', 'yes', 'on'], true);

Handles SQLite/MySQL integers (0/1), PostgreSQL booleans ('t'/'f'), and native PHP booleans.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: ljonesfl <1099983+ljonesfl@users.noreply.github.com>
@ljonesfl ljonesfl marked this pull request as ready for review November 11, 2025 03:54
Copilot AI changed the title [WIP] Address feedback on service architecture feature implementation Fix PostgreSQL boolean casting vulnerability in DatabaseUserRepository Nov 11, 2025
Copilot AI requested a review from ljonesfl November 11, 2025 03:55
Copilot finished work on behalf of ljonesfl November 11, 2025 03:55
@ljonesfl ljonesfl merged commit 190117c into feature/service-architecture Nov 11, 2025
2 checks passed
@ljonesfl ljonesfl deleted the copilot/sub-pr-6 branch November 11, 2025 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants