Title: Security review of authentication tokens
Author: Ian Dunn
Published: October 25, 2019

---

 [  ](https://profiles.wordpress.org/iandunn/) [Ian Dunn](https://profiles.wordpress.org/iandunn/)
7:35 pm _on_ October 25, 2019      

# Security review of authentication tokens

For [the Five for the Future project](https://make.wordpress.org/updates/2018/11/05/proposal-five-for-the-future-acknowledgement-page/),
I ended up writing some custom code for authentication tokens which are stateful,
have (cryptographically secure) random values, and can only be used once.

Those tokens will be used by companies to manage [their pledges](https://user-images.githubusercontent.com/541093/66067639-022e2600-e51a-11e9-8885-1be555a0f1ac.jpg),
so if an attacker was able to obtain a token, they’d be able to change a company’s
name, logo, description, etc to something inappropriate, remove contributors from
the pledge, and deactivate the pledge entirely.

The reasons why authentication tokens were chosen is documented in [the commit](https://github.com/WordPress/five-for-the-future/commit/5ffca9420fbce401d36ec4c1d9e0d2def6bd1b86),
and additional background is available in [issue #34](https://github.com/WordPress/five-for-the-future/issues/34)
and [PR #46](https://github.com/WordPress/five-for-the-future/pull/46).

Does anyone have any thoughts on the code, think there are any missing test cases,
or see any other problems? If you think there’s an active vulnerability, **please
pingPing The act of sending a very small amount of data to an end point. Ping is
used in computer science to illicit a response from a target server to test it’s
connection. Ping is also a term used by Slack users to @ someone or send them a 
direct message (DM). Users might say something along the lines of “Ping me when 
the meeting starts.” me privately or [report it via HackerOne](https://hackerone.com/wordpress).**

### Share this:

 * [  Threads ](https://make.wordpress.org/meta/2019/10/25/security-review-of-authentication-tokens/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/meta/2019/10/25/security-review-of-authentication-tokens/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/meta/2019/10/25/security-review-of-authentication-tokens/?share=bluesky)
 * [  X ](https://make.wordpress.org/meta/2019/10/25/security-review-of-authentication-tokens/?share=x)
 * [  Facebook ](https://make.wordpress.org/meta/2019/10/25/security-review-of-authentication-tokens/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/meta/2019/10/25/security-review-of-authentication-tokens/?share=linkedin)

 * [Login to Reply](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fmeta%2F2019%2F10%2F25%2Fsecurity-review-of-authentication-tokens%2F%23respond&locale=en_US)

 1. ![](https://secure.gravatar.com/avatar/5783a2d9b93f04f6d0a1ddabddcfd71f15136d7eaea7a87f9962d3f93f780224?
    s=32&d=mm&r=g)
 2.  [Ian Dunn](https://profiles.wordpress.org/iandunn/)  8:56 pm _on_ October 25, 
    2019
 3. Props [@timothyblynjacobs](https://profiles.wordpress.org/timothyblynjacobs/) for
    pointing out that `===` was used instead of `hash_equals()`. Fixed in [35fa9932](https://github.com/WordPress/five-for-the-future/commit/35fa99324eecf19b0205a8accb42789238f0fa0e).

### Leave a Reply 󠀁[Cancel reply](https://make.wordpress.org/meta/2019/10/25/security-review-of-authentication-tokens/?output_format=md#respond)󠁿

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fmeta%2F2019%2F10%2F25%2Fsecurity-review-of-authentication-tokens%2F&locale=en_US)
to post a comment.

# Post navigation

[← Next WordCamp.org ticket scrub on October 17th, 2019](https://make.wordpress.org/meta/2019/10/10/next-wordcamp-org-ticket-scrub-on-october-17th-2019/)

[WordCamp.org “office hour” on Nov 21st, 2019 →](https://make.wordpress.org/meta/2019/11/19/wordcamp-org-developer-office-hour-on-nov-21st-2019/)