Blog · November 2026 · 8 min read Blog · Novembre 2026 · 8 min de lectureالمدونة · نوفمبر 2026 · 8 دقائق قراءة

When "she has an account" is health data Quand « elle a un compte » est une donnée de santéعندما يصبح «لديها حساب» معلومة صحية

SheCare is a companion app for women going through breast cancer. In an app like this, the data is the diagnosis: even knowing that someone is registered says something about her health. What the app protected well, and three leaks I found when I reread my own code. SheCare est une application d'accompagnement pour les femmes atteintes d'un cancer du sein. Dans une appli comme celle-ci, la donnée, c'est le diagnostic : même savoir qu'une personne est inscrite en dit long sur sa santé. Ce que l'appli protégeait bien, et trois fuites que j'ai trouvées en relisant mon propre code.SheCare تطبيق لمرافقة النساء المصابات بسرطان الثدي. في تطبيق كهذا، البيانات هي التشخيص نفسه: فحتى معرفة أن امرأة مسجّلة فيه تكشف شيئاً عن صحتها. ما كان التطبيق يحميه جيداً، وثلاثة تسريبات وجدتها عندما أعدت قراءة شيفرتي.

The projectLe projetالمشروع

SheCare started at Startup Weekend Algiers 2025 as a front-end prototype built by our team of three. Later I rebuilt it alone as a complete application: Next.js 14 with Server Actions, PostgreSQL through Prisma, and Auth.js for accounts. A user can track her daily energy, mood and symptoms, write a private journal, share stories with the community, and book a consultation with a specialist. SheCare a commencé au Startup Weekend Algiers 2025, comme un prototype d'interface construit par notre équipe de trois. Plus tard, je l'ai reconstruit seul en application complète : Next.js 14 avec des Server Actions, PostgreSQL via Prisma, et Auth.js pour les comptes. Une utilisatrice peut suivre son énergie, son humeur et ses symptômes au quotidien, écrire un journal privé, partager son histoire avec la communauté et réserver une consultation avec un spécialiste.بدأ SheCare في Startup Weekend Algiers 2025 كنموذج أولي للواجهة بناه فريقنا المكوّن من ثلاثة أشخاص. ثم أعدت بناءه وحدي كتطبيق كامل: Next.js 14 مع Server Actions، وPostgreSQL عبر Prisma، وAuth.js للحسابات. تستطيع المستخدمة متابعة طاقتها ومزاجها وأعراضها يومياً، وكتابة يوميات خاصة، ومشاركة قصتها مع المجتمع، وحجز استشارة مع مختص.

Who are we protecting her from?De qui la protège-t-on ?ممّن نحميها؟

When we think about security, we picture an anonymous hacker. For a health app, the realistic risks are closer to home: a colleague who is curious, a partner who picks up her phone, an insurer or an employer, other members of the community. Many women do not tell everyone about their illness, and that choice belongs to them. So the question for every feature is: what could someone learn about her that she did not choose to share? Quand on pense sécurité, on imagine un hacker anonyme. Pour une appli de santé, les risques réalistes sont plus proches : une collègue curieuse, un conjoint qui prend son téléphone, un assureur ou un employeur, d'autres membres de la communauté. Beaucoup de femmes ne parlent pas de leur maladie à tout le monde, et ce choix leur appartient. La question à poser pour chaque fonctionnalité est donc : qu'est-ce que quelqu'un pourrait apprendre sur elle qu'elle n'a pas choisi de partager ?عندما نفكر في الأمن، نتخيل مخترقاً مجهولاً. أما في تطبيق صحي، فالمخاطر الواقعية أقرب: زميلة فضولية، أو شريك يأخذ هاتفها، أو شركة تأمين أو صاحب عمل، أو عضوات أخريات في المجتمع. كثير من النساء لا يخبرن الجميع بمرضهن، وهذا الاختيار يعود إليهن. لذلك فالسؤال أمام كل ميزة هو: ما الذي قد يعرفه شخص ما عنها دون أن تختار هي مشاركته؟

What the app already did rightCe que l'appli faisait déjà bienما كان التطبيق يفعله جيداً

  • Every query is scoped to the user. Deleting a symptom is deleteMany({ where: { id, userId } }), never just the id, so nobody can delete or read another person's records by changing an id in a request.Chaque requête est limitée à l'utilisatrice. Supprimer un symptôme, c'est deleteMany({ where: { id, userId } }), jamais juste l'id : personne ne peut lire ou supprimer les données d'une autre en changeant un id dans une requête.كل استعلام مقيَّد بالمستخدمة. حذف عرض ما يتم عبر deleteMany({ where: { id, userId } })، وليس بالمعرّف وحده، فلا يستطيع أحد قراءة أو حذف سجلات غيره بتغيير معرّف في الطلب.
  • Hidden names never reach the browser. If a user turns off profile visibility, the server replaces her name with "Community member" before rendering. The page only receives the text to display, not her real name hidden with CSS.Les noms masqués n'arrivent jamais au navigateur. Si une utilisatrice désactive la visibilité de son profil, le serveur remplace son nom par « Membre de la communauté » avant l'affichage. La page reçoit seulement le texte à afficher, pas son vrai nom caché en CSS.الأسماء المخفية لا تصل أبداً إلى المتصفح. إذا أوقفت المستخدمة ظهور ملفها، يستبدل الخادم اسمها بـ«عضوة في المجتمع» قبل العرض. فالصفحة تتلقى النص المعروض فقط، لا اسمها الحقيقي مخفياً بـ CSS.
  • She owns her data. She can download everything stored about her as JSON, and deleting the account removes all of her records through ON DELETE CASCADE, after asking for her password.Ses données lui appartiennent. Elle peut télécharger tout ce qui est enregistré sur elle en JSON, et la suppression du compte efface tous ses enregistrements grâce à ON DELETE CASCADE, après lui avoir demandé son mot de passe.بياناتها ملك لها. تستطيع تنزيل كل ما هو مخزَّن عنها بصيغة JSON، وحذف الحساب يزيل كل سجلاتها عبر ON DELETE CASCADE، بعد طلب كلمة مرورها.
  • Validation happens on the server with Zod, and passwords are hashed with bcrypt.La validation se fait côté serveur avec Zod, et les mots de passe sont hachés avec bcrypt.التحقق من المدخلات يتم في الخادم باستخدام Zod، وكلمات المرور مُجزَّأة بـ bcrypt.

That covers the classic web vulnerabilities. The leaks I found were quieter: places where the app answered a question it should not have answered. Ça couvre les failles web classiques. Les fuites que j'ai trouvées étaient plus discrètes : des endroits où l'appli répondait à une question à laquelle elle n'aurait pas dû répondre.هذا يغطي الثغرات الكلاسيكية في الويب. أما التسريبات التي وجدتها فكانت أهدأ: مواضع كان التطبيق يجيب فيها عن سؤال ما كان ينبغي أن يجيب عنه.

Leak 1: "is she registered?"Fuite 1 : « est-ce qu'elle est inscrite ? »التسريب 1: «هل هي مسجّلة؟»

The login code looked correct: Le code de connexion avait l'air correct :كانت شيفرة تسجيل الدخول تبدو صحيحة:

const user = await db.user.findUnique({ where: { email } })
if (!user) return null                          // answers in a few ms

const valid = await bcrypt.compare(password, user.passwordHash)   // about 230 ms
if (!valid) return null

Both failures show the same message, "Incorrect email or password". But bcrypt is slow on purpose: with cost 12, checking a password took about 230 milliseconds on my laptop. When the email does not exist, the function returns almost immediately. By timing a few login attempts with her email and any password, someone can tell whether she has an account, without ever knowing her password. In most apps that is a minor issue. In SheCare, it tells a colleague that she is probably being treated for breast cancer. Les deux échecs affichent le même message, « Email ou mot de passe incorrect ». Mais bcrypt est lent exprès : avec un coût de 12, vérifier un mot de passe prenait environ 230 millisecondes sur mon ordinateur. Quand l'email n'existe pas, la fonction répond presque tout de suite. En chronométrant quelques tentatives de connexion avec son email et n'importe quel mot de passe, quelqu'un peut savoir si elle a un compte, sans jamais connaître son mot de passe. Dans la plupart des applis, c'est un détail. Dans SheCare, ça apprend à une collègue qu'elle est probablement soignée pour un cancer du sein.كلا الفشلين يعرضان الرسالة نفسها، «البريد أو كلمة المرور غير صحيحة». لكن bcrypt بطيء عن قصد: بكلفة 12، كان التحقق من كلمة المرور يستغرق نحو 230 جزءاً من الألف من الثانية على حاسوبي. وعندما لا يكون البريد موجوداً، تعود الدالة فوراً تقريباً. فبقياس زمن بضع محاولات دخول ببريدها وبأي كلمة مرور، يستطيع شخص ما معرفة ما إذا كان لديها حساب، دون أن يعرف كلمة مرورها أبداً. في أغلب التطبيقات هذه مسألة ثانوية. أما في SheCare، فهي تخبر زميلة بأنها على الأرجح تتلقى علاجاً لسرطان الثدي.

The fix is to do the same work in both cases, by comparing against a dummy hash when the user does not exist: La correction : faire le même travail dans les deux cas, en comparant avec un faux hash quand l'utilisatrice n'existe pas :الحل هو القيام بالعمل نفسه في الحالتين، بالمقارنة مع تجزئة وهمية عندما لا تكون المستخدمة موجودة:

const DUMMY_HASH = bcrypt.hashSync("not-a-real-password", 12)   // computed once

const user = await db.user.findUnique({ where: { email } })
const valid = await bcrypt.compare(password, user?.passwordHash ?? DUMMY_HASH)
if (!user || !valid) return null                // same time either way

Being honest about the limit: the sign-up form still says "an account with this email already exists", which leaks the same information. The real fix is email verification, where both cases answer "check your inbox". SheCare does not send emails yet, so this one stays on the list, together with rate limiting on the login form. Pour être honnête sur la limite : le formulaire d'inscription dit encore « un compte existe déjà avec cet email », ce qui révèle la même information. La vraie solution, c'est la vérification par email, où les deux cas répondent « regardez votre boîte mail ». SheCare n'envoie pas encore d'emails, donc ce point reste sur la liste, avec la limitation du nombre de tentatives de connexion.وللأمانة بشأن الحدود: ما زال نموذج التسجيل يقول «يوجد حساب بهذا البريد»، وهذا يكشف المعلومة نفسها. الحل الحقيقي هو التحقق عبر البريد الإلكتروني، حيث تجيب الحالتان «تفقّدي بريدك». لا يرسل SheCare رسائل بريدية بعد، لذا تبقى هذه النقطة على القائمة، مع تحديد عدد محاولات تسجيل الدخول.

Leak 2: sessions that outlive the passwordFuite 2 : des sessions qui survivent au mot de passeالتسريب 2: جلسات تعيش أطول من كلمة المرور

Imagine she logged in on a shared tablet, or someone took her phone. She changes her password from her laptop and expects the other device to be locked out. It was not. Auth.js was configured with JWT sessions: the session is a signed cookie, and the server only checks the signature. Nothing in it depended on the password, so the old cookie stayed valid for its full lifetime, 30 days by default. Even after deleting her account, another device kept a valid session for a user who no longer existed. Imaginez qu'elle se soit connectée sur une tablette partagée, ou que quelqu'un ait pris son téléphone. Elle change son mot de passe depuis son ordinateur et s'attend à ce que l'autre appareil soit déconnecté. Ce n'était pas le cas. Auth.js était configuré avec des sessions JWT : la session est un cookie signé, et le serveur vérifie seulement la signature. Rien dedans ne dépendait du mot de passe, donc l'ancien cookie restait valable toute sa durée de vie, 30 jours par défaut. Même après la suppression du compte, un autre appareil gardait une session valide pour une utilisatrice qui n'existait plus.تخيّل أنها سجّلت الدخول على جهاز لوحي مشترك، أو أن أحداً أخذ هاتفها. تغيّر كلمة مرورها من حاسوبها وتتوقع أن يُطرد الجهاز الآخر. لكن ذلك لم يحدث. كان Auth.js مضبوطاً على جلسات JWT: الجلسة ملف تعريف ارتباط موقَّع، والخادم يتحقق من التوقيع فقط. لم يكن فيه شيء مرتبط بكلمة المرور، فبقي الملف القديم صالحاً طوال عمره، 30 يوماً افتراضياً. وحتى بعد حذف حسابها، بقيت لدى جهاز آخر جلسة صالحة لمستخدمة لم تعد موجودة.

A JWT cannot be revoked by itself, so the server needs one small piece of state to compare against. I added a sessionVersion number to each user, written into the token at login and checked on every request: Un JWT ne peut pas être révoqué tout seul, donc le serveur a besoin d'une petite information à laquelle le comparer. J'ai ajouté un numéro sessionVersion à chaque utilisatrice, écrit dans le jeton à la connexion et vérifié à chaque requête :لا يمكن إبطال JWT بمفرده، لذا يحتاج الخادم إلى معلومة صغيرة يقارن بها. أضفت رقماً sessionVersion لكل مستخدمة، يُكتب في الرمز عند الدخول ويُتحقق منه في كل طلب:

// at login: the token remembers the version it was issued for
token.sessionVersion = user.sessionVersion

// on every page and action
const user = await db.user.findUnique({ where: { id: token.id } })
if (!user || user.sessionVersion !== token.sessionVersion) signOutAndRedirect()

// changing the password ends every other session
await db.user.update({ where: { id }, data: { passwordHash, sessionVersion: { increment: 1 } } })

It costs one small database read per request, and a deleted account now ends all of its sessions immediately. Ça coûte une petite lecture en base par requête, et un compte supprimé met maintenant fin à toutes ses sessions immédiatement.الكلفة قراءة صغيرة من قاعدة البيانات في كل طلب، والحساب المحذوف ينهي الآن كل جلساته فوراً.

Leak 3: her export contained other peopleFuite 3 : son export contenait d'autres personnesالتسريب 3: تصدير بياناتها كان يحتوي على أشخاص آخرين

The "download my data" endpoint included her posts with their comments: La route « télécharger mes données » incluait ses posts avec leurs commentaires :كان مسار «تنزيل بياناتي» يتضمن منشوراتها مع تعليقاتها:

posts: { include: { comments: true } }   // every field of every comment

Those comments were written by other women, and comments: true exported every field, including each author's internal id, even for authors who had hidden their profile. An export is "everything about me", not "everything near me". The comments on her posts are still part of her story, so the export keeps their text and date, but no longer says who wrote them: Ces commentaires étaient écrits par d'autres femmes, et comments: true exportait tous les champs, y compris l'identifiant interne de chaque autrice, même pour celles qui avaient masqué leur profil. Un export, c'est « tout ce qui me concerne », pas « tout ce qui est autour de moi ». Les commentaires sous ses posts font quand même partie de son histoire, donc l'export garde leur texte et leur date, mais ne dit plus qui les a écrits :هذه التعليقات كتبتها نساء أخريات، وكان comments: true يصدّر كل الحقول، بما فيها المعرّف الداخلي لكل كاتبة، حتى لمن أخفين ملفاتهن. التصدير يعني «كل ما يخصني»، لا «كل ما حولي». التعليقات تحت منشوراتها تبقى جزءاً من قصتها، لذا يحتفظ التصدير بنصها وتاريخها، لكنه لم يعد يذكر من كتبها:

posts: { include: { comments: { select: { content: true, createdAt: true } } } }

The lesson is to choose fields explicitly with select whenever data leaves the server. include: true means "whatever the schema has today, and whatever someone adds tomorrow". La leçon : choisir les champs explicitement avec select dès que des données sortent du serveur. include: true veut dire « tout ce que le schéma contient aujourd'hui, et tout ce que quelqu'un ajoutera demain ».الدرس هو اختيار الحقول صراحةً بـ select كلما خرجت البيانات من الخادم. فـ include: true يعني «كل ما في المخطط اليوم، وكل ما قد يضيفه أحدهم غداً».

A privacy promise the code did not keepUne promesse de confidentialité que le code ne tenait pasوعد بالخصوصية لم تفِ به الشيفرة

The README listed "an option to post anonymously" in the community. There was no such option per post: there was a profile-wide visibility setting that hides her name everywhere. For most features, a README that oversells is just embarrassing. For privacy, it is dangerous: someone could share something personal believing it was anonymous. Privacy promises must describe exactly what the code does, so the README now describes the real setting. Le README annonçait « une option pour poster anonymement » dans la communauté. Cette option par post n'existait pas : il y avait un réglage de visibilité du profil, qui masque son nom partout. Pour la plupart des fonctionnalités, un README qui en promet trop est juste gênant. Pour la vie privée, c'est dangereux : quelqu'un pourrait partager quelque chose de personnel en croyant être anonyme. Une promesse de confidentialité doit décrire exactement ce que fait le code, donc le README décrit maintenant le vrai réglage.كان ملف README يذكر «خياراً للنشر دون الكشف عن الهوية» في المجتمع. لم يكن هذا الخيار موجوداً لكل منشور: كان هناك إعداد لظهور الملف الشخصي يخفي اسمها في كل مكان. في أغلب الميزات، يكون README المبالغ فيه محرجاً فقط. أما في الخصوصية، فهو خطير: قد تشارك إحداهن أمراً شخصياً معتقدةً أنها مجهولة. يجب أن يصف وعد الخصوصية بالضبط ما تفعله الشيفرة، لذا أصبح README يصف الإعداد الحقيقي.

And one bug that was just a bugEt un bug qui n'était qu'un bugوخطأ لم يكن إلا خطأً

Bookings were safe on the server: a serializable transaction checks overlaps for both the specialist and the patient, so two people cannot take the same slot. But the booking form only greyed out the exact start times already taken. Some consultations last 45 or 60 minutes, so after a one-hour booking at 10:00, the form still offered 10:30, and the user got an error when she picked it. The form now greys out every start time that would overlap an existing appointment, hers included. Côté serveur, les réservations étaient sûres : une transaction sérialisable vérifie les chevauchements pour le spécialiste et pour la patiente, donc deux personnes ne peuvent pas prendre le même créneau. Mais le formulaire grisait seulement les heures de début déjà prises. Certaines consultations durent 45 ou 60 minutes : après une réservation d'une heure à 10h00, le formulaire proposait encore 10h30, et l'utilisatrice recevait une erreur en le choisissant. Le formulaire grise maintenant toutes les heures qui chevaucheraient un rendez-vous existant, y compris les siens.في الخادم، كانت الحجوزات آمنة: معاملة من نوع serializable تتحقق من التداخل للمختص وللمريضة معاً، فلا يمكن لشخصين أخذ الموعد نفسه. لكن نموذج الحجز كان يعطّل فقط أوقات البدء المحجوزة بالضبط. بعض الاستشارات تدوم 45 أو 60 دقيقة، فبعد حجز ساعة عند 10:00 كان النموذج ما زال يعرض 10:30، وتتلقى المستخدمة خطأً عند اختياره. أصبح النموذج الآن يعطّل كل وقت بدء يتداخل مع موعد قائم، بما في ذلك مواعيدها.

TakeawaysÀ retenirالخلاصة

  • In a health app, metadata is health data: an account, a login time, a booking with an oncologist.Dans une appli de santé, les métadonnées sont des données de santé : un compte, une heure de connexion, un rendez-vous chez un oncologue.في تطبيق صحي، البيانات الوصفية بيانات صحية: حساب، أو وقت دخول، أو موعد مع طبيب أورام.
  • An error message is not the only answer an endpoint gives: response time answers too.Le message d'erreur n'est pas la seule réponse d'une route : le temps de réponse répond aussi.رسالة الخطأ ليست الجواب الوحيد للمسار: زمن الاستجابة يجيب أيضاً.
  • Changing a password or deleting an account must end every session, which stateless JWTs do not do on their own.Changer de mot de passe ou supprimer son compte doit mettre fin à toutes les sessions, ce que les JWT sans état ne font pas tout seuls.تغيير كلمة المرور أو حذف الحساب يجب أن ينهي كل الجلسات، وهذا ما لا تفعله رموز JWT عديمة الحالة وحدها.
  • Select fields explicitly when data leaves the server, and make privacy promises match the code exactly.Choisir les champs explicitement quand des données sortent du serveur, et faire correspondre exactement les promesses de confidentialité au code.اختر الحقول صراحةً عندما تخرج البيانات من الخادم، واجعل وعود الخصوصية مطابقة للشيفرة تماماً.

The code of SheCare (Next.js, Prisma, Auth.js) is on GitHub. Le code de SheCare (Next.js, Prisma, Auth.js) est sur GitHub.شيفرة SheCare ‏(Next.js وPrisma وAuth.js) موجودة على GitHub.