# Insufficient Logging (CWE-778) When a security-critical event occurs, the product either does not record the event or omits important details about the event when logging it. **Stack:** JavaScript - Prevalence: Wysoka Często wykorzystywana - Impact: Średni Zalecany przegląd - Prevention: Udokumentowane 3 przykładów poprawek **OWASP:** Security Logging and Monitoring Failures (A09:2021-Security Logging and Monitoring Failures) - #9 ## Description Insufficient logging makes it difficult to detect attacks in progress, investigate security incidents, or establish accountability. Logs should capture who did what, when, and from where. ## Prevention Strategie zapobiegania dla Insufficient Logging oparte na 1 regułach detekcji Shoulder. ### JavaScript Replace console.log with a structured logging library like winston or pino ## Warning Signs - [low] console ## Consequences - Ukrywanie aktywności - Obejście mechanizmu ochrony ## Mitigations - Loguj wszystkie zdarzenia istotne dla bezpieczeństwa (uwierzytelnianie, autoryzacja, dostęp do danych) - Dołączaj wystarczający kontekst (użytkownik, znacznik czasu, IP, akcja, wynik) - Wdroż scentralizowane zarządzanie i monitorowanie logów ## Detection - Total rules: 3 - Languages: javascript, typescript, python ## Rules by Language ### Javascript (1 rules) - **Avoid console.log when logging library exists** [low]: Detects console.log calls when a logging library exists. Only fires when winston, pino, bunyan, or log4js is detected. - Remediation: Replace console.log with your logging library. ```javascript // winston logger.info('User logged in', { userId }); // pino logger.info({ userId }, 'User logged in'); ``` Learn more: https://shoulder.dev/learn/javascript/cwe-778/avoid-console-log ### Typescript (1 rules) - **Avoid console.log when logging library exists** [low]: Detects console.log calls when a logging library exists. Only fires when winston, pino, bunyan, or log4js is detected. - Remediation: Replace console.log with your logging library. ```javascript // winston logger.info('User logged in', { userId }); // pino logger.info({ userId }, 'User logged in'); ``` Learn more: https://shoulder.dev/learn/javascript/cwe-778/avoid-console-log