Giter Club home page Giter Club logo

Comments (2)

 avatar commented on May 22, 2024

No it's not. DB encoding shouldn't be relied on for a security control, you should always sanitize input on receipt (from any data source eg user input), db read and write etc.

This lib uses PDO which has some protection against common sql vulnerabilities, but there are several other ways your code can be vulnerable. Have a look at my other posts for an example, such as JavaScript into the DB.

Note, I don't speak for the project

from php-auth.

ocram avatar ocram commented on May 22, 2024

Thanks for your question!

Yes, there may be security implications when using the broken utf8 instead of the proper utf8mb4, but I'm currently not aware of any. That being said, if you follow the README and do what the examples suggest, you should be safe using utf8.

For utf8mb4 support, you only need MySQL 5.5.3+ or a recent MariaDB version, which have been available for quite some time now (several years). As a recommendation, I would thus say you should upgrade your database engine's version, which you ultimately have to do at some point, anyway.

One thing that you will definitely experience is data loss. If non-BMP characters are used in usernames, email addresses or other strings passed to this library, it depends on MySQL's settings what happens. If MySQL is in "strict mode", it should throw an error. Otherwise, MySQL will probably accept the input and fail silently, simply truncating everything starting with the first non-BMP character. So foo💩bar might become just foo.

If we have learned anything from the past, especially from problems with null bytes, it's that silent data truncation is often dangerous.

For international products on global markets, with support for the non-English world, including any minor languages, probably also for emoji support, utf8mb4 is a must!

Apart from data loss, the only implication for security that I could imagine right now is truncated email addresses that cause unexpected behavior. Something like

[email protected]💩.evil.example.com

becoming

in the database while the verification email goes to the evil.example.com host. You would have to check the specifications for the local part and domain part of email addresses to check what's really possible here.

That should, however, be prevented by the internal syntax checks for email addresses, which are performed automatically. The effectiveness of those checks will depend on the behavior of PHP's \filter_var function with the \FILTER_VALIDATE_EMAIL flag, though, which might change in future versions.

Hope that helps!

from php-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.