Language: PHP
Label: vulnerable
CWE: CWE-346 \u2014 Origin Validation Error
The product does not properly verify that the source of data or communication is valid.

Code:
    public function onOpen(ConnectionInterface $conn)
    {
        // WebSockets from the Browser
        $sid = $this->getSid($conn);
        if ($sid != null) {
            $path = $this->getPath($conn);

            if (in_array($path, $this->single)) {
                if (array_key_exists($sid, $this->singlelocks)
                && array_key_exists($path, $this->singlelocks[$sid])) {
                    $this->singlelocks[$sid][$path]++;
                    $conn->close(1008);
                } else {
                    $this->singlelocks[$sid][$path] = 1;
                }
            }

            if (!array_key_exists($sid, $this->sessions)) {
                $language = $this->getLanguage($conn);
                $offset = $this->getOffset($conn);

                $this->sessions[$sid] = new Session(
                    $this->loop,
                    $sid,
                    $this->baseuri,
                    config('daemon.port'),
                    $this->key,
                    $language,
                    $offset,
                    config('daemon.verbose'),
                    config('daemon.debug')
                );
            }

            $this->sessions[$sid]->attach($conn);
        } else {
            // WebSocket from the internal subprocess
            $sid = $this->getHeaderSid($conn);
            if ($sid != null && isset($this->sessions[$sid])) {
                $this->sessions[$sid]->attachInternal($conn);

                $obj = new \StdClass;
                $obj->func = 'started';
                $this->sessions[$sid]->messageOut(json_encode($obj));
            }
        }
    }