Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3344978
D8956.id30875.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D8956.id30875.diff
View Options
diff --git a/keyserver/src/socket/tunnelbroker.js b/keyserver/src/socket/tunnelbroker.js
--- a/keyserver/src/socket/tunnelbroker.js
+++ b/keyserver/src/socket/tunnelbroker.js
@@ -3,6 +3,7 @@
import WebSocket from 'ws';
import {
+ refreshKeysTBMessageValidator,
type TBKeyserverConnectionInitializationMessage,
type TBMessage,
tunnelbrokerMessageTypes,
@@ -28,7 +29,11 @@
}
function handleTBMessageEvent(event: ArrayBuffer): Promise<void> {
- const message: TBMessage = JSON.parse(event.toString());
+ const rawMessage = JSON.parse(event.toString());
+ if (!refreshKeysTBMessageValidator.is(rawMessage)) {
+ throw new ServerError('unsupported_tunnelbroker_message');
+ }
+ const message: TBMessage = rawMessage;
if (message.type === tunnelbrokerMessageTypes.REFRESH_KEYS_REQUEST) {
return uploadNewOneTimeKeys(message.numberOfKeys);
diff --git a/lib/types/tunnelbroker-messages.js b/lib/types/tunnelbroker-messages.js
--- a/lib/types/tunnelbroker-messages.js
+++ b/lib/types/tunnelbroker-messages.js
@@ -1,5 +1,9 @@
// @flow
+import t, { type TInterface } from 'tcomb';
+
+import { tShape, tString } from '../utils/validation-utils.js';
+
type TBSharedConnectionInitializationMessage = {
+type: 'sessionRequest',
+deviceId: string,
@@ -39,6 +43,13 @@
+numberOfKeys: number,
};
+export const refreshKeysTBMessageValidator: TInterface<TBRefreshKeysRequest> =
+ tShape<TBRefreshKeysRequest>({
+ type: tString('RefreshKeyRequest'),
+ deviceId: t.String,
+ numberOfKeys: t.Number,
+ });
+
// Disjoint enumeration of all messages
// Currently, only a single message
export type TBMessage = TBRefreshKeysRequest;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 5:01 AM (17 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569020
Default Alt Text
D8956.id30875.diff (1 KB)
Attached To
Mode
D8956: [Keyserver] Validate incoming tunnelbroker messages
Attached
Detach File
Event Timeline
Log In to Comment