瀏覽代碼

Fix Security issue: Hyperlink injection.

Thanks to mc-marcy and xet7 !

Fixes #5176
Lauri Ojansivu 1 年之前
父節點
當前提交
4fe168b03b
共有 1 個文件被更改,包括 61 次插入1 次删除
  1. 61 1
      models/users.js

+ 61 - 1
models/users.js

@@ -1325,6 +1325,14 @@ if (Meteor.isServer) {
       check(importUsernames, Array);
       check(importUsernames, Array);
       check(userOrgsArray, Array);
       check(userOrgsArray, Array);
       check(userTeamsArray, Array);
       check(userTeamsArray, Array);
+      // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+      // Thanks to mc-marcy and xet7 !
+      if (fullname.includes('/') ||
+         username.includes('/') ||
+         email.includes('/') ||
+         initials.includes('/')) {
+         return false;
+      }
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
         const nUsersWithUsername = ReactiveCache.getUsers({
         const nUsersWithUsername = ReactiveCache.getUsers({
           username,
           username,
@@ -1365,6 +1373,12 @@ if (Meteor.isServer) {
     setUsername(username, userId) {
     setUsername(username, userId) {
       check(username, String);
       check(username, String);
       check(userId, String);
       check(userId, String);
+      // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+      // Thanks to mc-marcy and xet7 !
+      if (username.includes('/') ||
+         userId.includes('/')) {
+         return false;
+      }
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
         const nUsersWithUsername = ReactiveCache.getUsers({
         const nUsersWithUsername = ReactiveCache.getUsers({
           username,
           username,
@@ -1383,6 +1397,12 @@ if (Meteor.isServer) {
     setEmail(email, userId) {
     setEmail(email, userId) {
       check(email, String);
       check(email, String);
       check(username, String);
       check(username, String);
+      // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+      // Thanks to mc-marcy and xet7 !
+      if (username.includes('/') ||
+         email.includes('/')) {
+         return false;
+      }
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
         if (Array.isArray(email)) {
         if (Array.isArray(email)) {
           email = email.shift();
           email = email.shift();
@@ -1417,6 +1437,13 @@ if (Meteor.isServer) {
       check(username, String);
       check(username, String);
       check(email, String);
       check(email, String);
       check(userId, String);
       check(userId, String);
+      // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+      // Thanks to mc-marcy and xet7 !
+      if (username.includes('/') ||
+         email.includes('/') ||
+         userId.includes('/')) {
+         return false;
+      }
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
         if (Array.isArray(email)) {
         if (Array.isArray(email)) {
           email = email.shift();
           email = email.shift();
@@ -1436,6 +1463,12 @@ if (Meteor.isServer) {
       check(email, String);
       check(email, String);
       check(verified, Boolean);
       check(verified, Boolean);
       check(userId, String);
       check(userId, String);
+      // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+      // Thanks to mc-marcy and xet7 !
+      if (email.includes('/') ||
+         userId.includes('/')) {
+         return false;
+      }
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
         Users.update(userId, {
         Users.update(userId, {
           $set: {
           $set: {
@@ -1452,6 +1485,12 @@ if (Meteor.isServer) {
     setInitials(initials, userId) {
     setInitials(initials, userId) {
       check(initials, String);
       check(initials, String);
       check(userId, String);
       check(userId, String);
+      // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+      // Thanks to mc-marcy and xet7 !
+      if (initials.includes('/') ||
+         userId.includes('/')) {
+         return false;
+      }
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
       if (ReactiveCache.getCurrentUser()?.isAdmin) {
         Users.update(userId, {
         Users.update(userId, {
           $set: {
           $set: {
@@ -1464,7 +1503,12 @@ if (Meteor.isServer) {
     inviteUserToBoard(username, boardId) {
     inviteUserToBoard(username, boardId) {
       check(username, String);
       check(username, String);
       check(boardId, String);
       check(boardId, String);
-
+      // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+      // Thanks to mc-marcy and xet7 !
+      if (username.includes('/') ||
+          boardId.includes('/')) {
+         return false;
+      }
       const inviter = ReactiveCache.getCurrentUser();
       const inviter = ReactiveCache.getCurrentUser();
       const board = ReactiveCache.getBoard(boardId);
       const board = ReactiveCache.getBoard(boardId);
       const allowInvite =
       const allowInvite =
@@ -1507,6 +1551,12 @@ if (Meteor.isServer) {
         // Set in lowercase email before creating account
         // Set in lowercase email before creating account
         const email = username.toLowerCase();
         const email = username.toLowerCase();
         username = email.substring(0, posAt);
         username = email.substring(0, posAt);
+        // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+        // Thanks to mc-marcy and xet7 !
+        if (username.includes('/') ||
+           email.includes('/')) {
+           return false;
+        }
         const newUserId = Accounts.createUser({
         const newUserId = Accounts.createUser({
           username,
           username,
           email,
           email,
@@ -1687,6 +1737,16 @@ if (Meteor.isServer) {
           verified: true,
           verified: true,
         },
         },
       ];
       ];
+
+
+      // Prevent Hyperlink Injection https://github.com/wekan/wekan/issues/5176
+      // Thanks to mc-marcy and xet7 !
+      if (user.username.includes('/') ||
+         email.includes('/')) {
+         return false;
+      }
+
+
       const initials = user.services.oidc.fullname
       const initials = user.services.oidc.fullname
         .split(/\s+/)
         .split(/\s+/)
         .reduce((memo, word) => {
         .reduce((memo, word) => {