Giter Site home page Giter Site logo

secretchat.site's People

Contributors

dustball avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

secretchat.site's Issues

Use of cryptographically insecure PRNG

Hi @dustball,

Summary

A PRNG is an algorithm used to produce random-looking numbers with certain desirable statistical properties. In order for a PRNG to be cryptographically secure it must be resistant to prediction.

secretchat.site currently uses Math.random() as a pseudo-random number generator which is not a cryptographically secure PRNG.

The PRNG is implemented in room.php when generating an IV as follows:

function make_iv() {
        var text = "";
        var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        for( var i=0; i < 16; i++ )
          text += possible.charAt(Math.floor(Math.random() * possible.length));
        return text;
}

Link to source code: https://github.com/dustball/secretchat.site/blob/master/www/room.php#L234-L240

The PRNG is again implemented in index.php to generate salts:

function make_salt() {
  var text = "";
  var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  for( var i=0; i < 16; i++ )
    text += possible.charAt(Math.floor(Math.random() * possible.length));
  return text;
}

Link to source code: https://github.com/dustball/secretchat.site/blob/master/www/index.php#L94-L100

How can this be fixed?

You could either implement a CPRNG from a library or use the Web Crypto API.

Best regards,
Ed

PHP code is off

<?php

if (!$_SERVER['HTTPS']) {
  header('Location: https://secretchat.site/');
  exit;
}

You should just force HTTPS on the site and use a sameorigin header and it'd be better.

Errors are inconsistent

https://secretchat.site/room/ gives a status code of 200
and
https://secretchat.site/TEST/ gives a status code of 404

I'd suggest if someone directly accesses something, you execute some server-side code.
Such as, anything that would be 403 should route to 404. Then the 404 page should have something like this:

<?php
http_response_code(404);
?>

Which makes it harder to tell whether something is truly not there, or forbidden.

No Cloudflare?

Right now your IP is out in the open to anyone who pings or accesses the site. Are you worried about a DDoS or other attack on your server?

Generation of Rooms

Couple issues.

  1. You're using input for the room and just wrapping it in a sha1 function.
  2. What exactly are you using to "encrypt" conversations, and why do users not have access to their own keys ( and preferably, can generate their own )?
  3. Why does "password" need to equal the sha1 hashed room name? What's password even for?

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.