We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7b974cb commit 3c4037aCopy full SHA for 3c4037a
1 file changed
packages/next/server/crypto-utils.js
@@ -0,0 +1,19 @@
1
+const MAX_BUFFER_SIZE = 1024; // 1KB
2
+
3
+function safeBufferConversion(input, encoding = 'hex') {
4
+ if (input.length > MAX_BUFFER_SIZE * 2 && encoding === 'hex') {
5
+ throw new SecurityError('Input exceeds maximum allowed size');
6
+ }
7
+ return Buffer.from(input, encoding);
8
+}
9
10
+class SecurityError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = 'SecurityError';
14
+ // Remove stack trace for production
15
+ if (process.env.NODE_ENV === 'production') {
16
+ this.stack = undefined;
17
18
19
0 commit comments